blob: 31ab92eda45d5d275fe9f64aaa52084b9fe04e20 [file] [log] [blame]
Ben Gamari20172632009-02-17 20:08:50 -05001/*
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
Chris Wilsonf3cd4742009-10-13 22:20:20 +010029#include <linux/debugfs.h>
Chris Wilsone637d2c2017-03-16 13:19:57 +000030#include <linux/sort.h>
Peter Zijlstrad92a8cf2017-03-03 10:13:38 +010031#include <linux/sched/mm.h>
Simon Farnsworth4e5359c2010-09-01 17:47:52 +010032#include "intel_drv.h"
Michal Wajdeczko9f436c42017-10-04 18:13:40 +000033#include "i915_guc_submission.h"
Ben Gamari20172632009-02-17 20:08:50 -050034
David Weinehall36cdd012016-08-22 13:59:31 +030035static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node)
36{
37 return to_i915(node->minor->dev);
38}
39
Chris Wilson418e3cd2017-02-06 21:36:08 +000040static __always_inline void seq_print_param(struct seq_file *m,
41 const char *name,
42 const char *type,
43 const void *x)
44{
45 if (!__builtin_strcmp(type, "bool"))
46 seq_printf(m, "i915.%s=%s\n", name, yesno(*(const bool *)x));
47 else if (!__builtin_strcmp(type, "int"))
48 seq_printf(m, "i915.%s=%d\n", name, *(const int *)x);
49 else if (!__builtin_strcmp(type, "unsigned int"))
50 seq_printf(m, "i915.%s=%u\n", name, *(const unsigned int *)x);
Chris Wilson1d6aa7a2017-02-21 16:26:19 +000051 else if (!__builtin_strcmp(type, "char *"))
52 seq_printf(m, "i915.%s=%s\n", name, *(const char **)x);
Chris Wilson418e3cd2017-02-06 21:36:08 +000053 else
54 BUILD_BUG();
55}
56
Chris Wilson70d39fe2010-08-25 16:03:34 +010057static int i915_capabilities(struct seq_file *m, void *data)
58{
David Weinehall36cdd012016-08-22 13:59:31 +030059 struct drm_i915_private *dev_priv = node_to_i915(m->private);
60 const struct intel_device_info *info = INTEL_INFO(dev_priv);
Chris Wilson70d39fe2010-08-25 16:03:34 +010061
David Weinehall36cdd012016-08-22 13:59:31 +030062 seq_printf(m, "gen: %d\n", INTEL_GEN(dev_priv));
Jani Nikula2e0d26f2016-12-01 14:49:55 +020063 seq_printf(m, "platform: %s\n", intel_platform_name(info->platform));
David Weinehall36cdd012016-08-22 13:59:31 +030064 seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev_priv));
Chris Wilson418e3cd2017-02-06 21:36:08 +000065
Damien Lespiau79fc46d2013-04-23 16:37:17 +010066#define PRINT_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x))
Joonas Lahtinen604db652016-10-05 13:50:16 +030067 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG);
Damien Lespiau79fc46d2013-04-23 16:37:17 +010068#undef PRINT_FLAG
Chris Wilson70d39fe2010-08-25 16:03:34 +010069
Chris Wilson418e3cd2017-02-06 21:36:08 +000070 kernel_param_lock(THIS_MODULE);
Michal Wajdeczko7075cb852017-09-25 10:50:07 +000071#define PRINT_PARAM(T, x, ...) seq_print_param(m, #x, #T, &i915_modparams.x);
Chris Wilson418e3cd2017-02-06 21:36:08 +000072 I915_PARAMS_FOR_EACH(PRINT_PARAM);
73#undef PRINT_PARAM
74 kernel_param_unlock(THIS_MODULE);
75
Chris Wilson70d39fe2010-08-25 16:03:34 +010076 return 0;
77}
Ben Gamari433e12f2009-02-17 20:08:51 -050078
Imre Deaka7363de2016-05-12 16:18:52 +030079static char get_active_flag(struct drm_i915_gem_object *obj)
Chris Wilsona6172a82009-02-11 14:26:38 +000080{
Chris Wilson573adb32016-08-04 16:32:39 +010081 return i915_gem_object_is_active(obj) ? '*' : ' ';
Chris Wilsona6172a82009-02-11 14:26:38 +000082}
83
Imre Deaka7363de2016-05-12 16:18:52 +030084static char get_pin_flag(struct drm_i915_gem_object *obj)
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +010085{
86 return obj->pin_display ? 'p' : ' ';
87}
88
Imre Deaka7363de2016-05-12 16:18:52 +030089static char get_tiling_flag(struct drm_i915_gem_object *obj)
Chris Wilsona6172a82009-02-11 14:26:38 +000090{
Chris Wilson3e510a82016-08-05 10:14:23 +010091 switch (i915_gem_object_get_tiling(obj)) {
Akshay Joshi0206e352011-08-16 15:34:10 -040092 default:
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +010093 case I915_TILING_NONE: return ' ';
94 case I915_TILING_X: return 'X';
95 case I915_TILING_Y: return 'Y';
Akshay Joshi0206e352011-08-16 15:34:10 -040096 }
Chris Wilsona6172a82009-02-11 14:26:38 +000097}
98
Imre Deaka7363de2016-05-12 16:18:52 +030099static char get_global_flag(struct drm_i915_gem_object *obj)
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700100{
Chris Wilsona65adaf2017-10-09 09:43:57 +0100101 return obj->userfault_count ? 'g' : ' ';
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100102}
103
Imre Deaka7363de2016-05-12 16:18:52 +0300104static char get_pin_mapped_flag(struct drm_i915_gem_object *obj)
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100105{
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100106 return obj->mm.mapping ? 'M' : ' ';
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700107}
108
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100109static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)
110{
111 u64 size = 0;
112 struct i915_vma *vma;
113
Chris Wilson1c7f4bc2016-02-26 11:03:19 +0000114 list_for_each_entry(vma, &obj->vma_list, obj_link) {
Chris Wilson3272db52016-08-04 16:32:32 +0100115 if (i915_vma_is_ggtt(vma) && drm_mm_node_allocated(&vma->node))
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100116 size += vma->node.size;
117 }
118
119 return size;
120}
121
Matthew Auld7393b7e2017-10-06 23:18:28 +0100122static const char *
123stringify_page_sizes(unsigned int page_sizes, char *buf, size_t len)
124{
125 size_t x = 0;
126
127 switch (page_sizes) {
128 case 0:
129 return "";
130 case I915_GTT_PAGE_SIZE_4K:
131 return "4K";
132 case I915_GTT_PAGE_SIZE_64K:
133 return "64K";
134 case I915_GTT_PAGE_SIZE_2M:
135 return "2M";
136 default:
137 if (!buf)
138 return "M";
139
140 if (page_sizes & I915_GTT_PAGE_SIZE_2M)
141 x += snprintf(buf + x, len - x, "2M, ");
142 if (page_sizes & I915_GTT_PAGE_SIZE_64K)
143 x += snprintf(buf + x, len - x, "64K, ");
144 if (page_sizes & I915_GTT_PAGE_SIZE_4K)
145 x += snprintf(buf + x, len - x, "4K, ");
146 buf[x-2] = '\0';
147
148 return buf;
149 }
150}
151
Chris Wilson37811fc2010-08-25 22:45:57 +0100152static void
153describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
154{
Chris Wilsonb4716182015-04-27 13:41:17 +0100155 struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000156 struct intel_engine_cs *engine;
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700157 struct i915_vma *vma;
Chris Wilsonfaf5bf02016-08-04 16:32:37 +0100158 unsigned int frontbuffer_bits;
Ben Widawskyd7f46fc2013-12-06 14:10:55 -0800159 int pin_count = 0;
160
Chris Wilson188c1ab2016-04-03 14:14:20 +0100161 lockdep_assert_held(&obj->base.dev->struct_mutex);
162
Chris Wilsond07f0e52016-10-28 13:58:44 +0100163 seq_printf(m, "%pK: %c%c%c%c%c %8zdKiB %02x %02x %s%s%s",
Chris Wilson37811fc2010-08-25 22:45:57 +0100164 &obj->base,
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100165 get_active_flag(obj),
Chris Wilson37811fc2010-08-25 22:45:57 +0100166 get_pin_flag(obj),
167 get_tiling_flag(obj),
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700168 get_global_flag(obj),
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +0100169 get_pin_mapped_flag(obj),
Eric Anholta05a5862011-12-20 08:54:15 -0800170 obj->base.size / 1024,
Chris Wilson37811fc2010-08-25 22:45:57 +0100171 obj->base.read_domains,
Chris Wilsond07f0e52016-10-28 13:58:44 +0100172 obj->base.write_domain,
David Weinehall36cdd012016-08-22 13:59:31 +0300173 i915_cache_level_str(dev_priv, obj->cache_level),
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100174 obj->mm.dirty ? " dirty" : "",
175 obj->mm.madv == I915_MADV_DONTNEED ? " purgeable" : "");
Chris Wilson37811fc2010-08-25 22:45:57 +0100176 if (obj->base.name)
177 seq_printf(m, " (name: %d)", obj->base.name);
Chris Wilson1c7f4bc2016-02-26 11:03:19 +0000178 list_for_each_entry(vma, &obj->vma_list, obj_link) {
Chris Wilson20dfbde2016-08-04 16:32:30 +0100179 if (i915_vma_is_pinned(vma))
Ben Widawskyd7f46fc2013-12-06 14:10:55 -0800180 pin_count++;
Dan Carpenterba0635ff2015-02-25 16:17:48 +0300181 }
182 seq_printf(m, " (pinned x %d)", pin_count);
Chris Wilsoncc98b412013-08-09 12:25:09 +0100183 if (obj->pin_display)
184 seq_printf(m, " (display)");
Chris Wilson1c7f4bc2016-02-26 11:03:19 +0000185 list_for_each_entry(vma, &obj->vma_list, obj_link) {
Chris Wilson15717de2016-08-04 07:52:26 +0100186 if (!drm_mm_node_allocated(&vma->node))
187 continue;
188
Matthew Auld7393b7e2017-10-06 23:18:28 +0100189 seq_printf(m, " (%sgtt offset: %08llx, size: %08llx, pages: %s",
Chris Wilson3272db52016-08-04 16:32:32 +0100190 i915_vma_is_ggtt(vma) ? "g" : "pp",
Matthew Auld7393b7e2017-10-06 23:18:28 +0100191 vma->node.start, vma->node.size,
192 stringify_page_sizes(vma->page_sizes.gtt, NULL, 0));
Chris Wilson21976852017-01-12 11:21:08 +0000193 if (i915_vma_is_ggtt(vma)) {
194 switch (vma->ggtt_view.type) {
195 case I915_GGTT_VIEW_NORMAL:
196 seq_puts(m, ", normal");
197 break;
198
199 case I915_GGTT_VIEW_PARTIAL:
200 seq_printf(m, ", partial [%08llx+%x]",
Chris Wilson8bab11932017-01-14 00:28:25 +0000201 vma->ggtt_view.partial.offset << PAGE_SHIFT,
202 vma->ggtt_view.partial.size << PAGE_SHIFT);
Chris Wilson21976852017-01-12 11:21:08 +0000203 break;
204
205 case I915_GGTT_VIEW_ROTATED:
206 seq_printf(m, ", rotated [(%ux%u, stride=%u, offset=%u), (%ux%u, stride=%u, offset=%u)]",
Chris Wilson8bab11932017-01-14 00:28:25 +0000207 vma->ggtt_view.rotated.plane[0].width,
208 vma->ggtt_view.rotated.plane[0].height,
209 vma->ggtt_view.rotated.plane[0].stride,
210 vma->ggtt_view.rotated.plane[0].offset,
211 vma->ggtt_view.rotated.plane[1].width,
212 vma->ggtt_view.rotated.plane[1].height,
213 vma->ggtt_view.rotated.plane[1].stride,
214 vma->ggtt_view.rotated.plane[1].offset);
Chris Wilson21976852017-01-12 11:21:08 +0000215 break;
216
217 default:
218 MISSING_CASE(vma->ggtt_view.type);
219 break;
220 }
221 }
Chris Wilson49ef5292016-08-18 17:17:00 +0100222 if (vma->fence)
223 seq_printf(m, " , fence: %d%s",
224 vma->fence->id,
225 i915_gem_active_isset(&vma->last_fence) ? "*" : "");
Chris Wilson596c5922016-02-26 11:03:20 +0000226 seq_puts(m, ")");
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700227 }
Chris Wilsonc1ad11f2012-11-15 11:32:21 +0000228 if (obj->stolen)
Thierry Reding440fd522015-01-23 09:05:06 +0100229 seq_printf(m, " (stolen: %08llx)", obj->stolen->start);
Chris Wilson27c01aa2016-08-04 07:52:30 +0100230
Chris Wilsond07f0e52016-10-28 13:58:44 +0100231 engine = i915_gem_object_last_write_engine(obj);
Chris Wilson27c01aa2016-08-04 07:52:30 +0100232 if (engine)
233 seq_printf(m, " (%s)", engine->name);
234
Chris Wilsonfaf5bf02016-08-04 16:32:37 +0100235 frontbuffer_bits = atomic_read(&obj->frontbuffer_bits);
236 if (frontbuffer_bits)
237 seq_printf(m, " (frontbuffer: 0x%03x)", frontbuffer_bits);
Chris Wilson37811fc2010-08-25 22:45:57 +0100238}
239
Chris Wilsone637d2c2017-03-16 13:19:57 +0000240static int obj_rank_by_stolen(const void *A, const void *B)
Chris Wilson6d2b88852013-08-07 18:30:54 +0100241{
Chris Wilsone637d2c2017-03-16 13:19:57 +0000242 const struct drm_i915_gem_object *a =
243 *(const struct drm_i915_gem_object **)A;
244 const struct drm_i915_gem_object *b =
245 *(const struct drm_i915_gem_object **)B;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100246
Rasmus Villemoes2d05fa12015-09-28 23:08:50 +0200247 if (a->stolen->start < b->stolen->start)
248 return -1;
249 if (a->stolen->start > b->stolen->start)
250 return 1;
251 return 0;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100252}
253
254static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
255{
David Weinehall36cdd012016-08-22 13:59:31 +0300256 struct drm_i915_private *dev_priv = node_to_i915(m->private);
257 struct drm_device *dev = &dev_priv->drm;
Chris Wilsone637d2c2017-03-16 13:19:57 +0000258 struct drm_i915_gem_object **objects;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100259 struct drm_i915_gem_object *obj;
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300260 u64 total_obj_size, total_gtt_size;
Chris Wilsone637d2c2017-03-16 13:19:57 +0000261 unsigned long total, count, n;
262 int ret;
263
264 total = READ_ONCE(dev_priv->mm.object_count);
Michal Hocko20981052017-05-17 14:23:12 +0200265 objects = kvmalloc_array(total, sizeof(*objects), GFP_KERNEL);
Chris Wilsone637d2c2017-03-16 13:19:57 +0000266 if (!objects)
267 return -ENOMEM;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100268
269 ret = mutex_lock_interruptible(&dev->struct_mutex);
270 if (ret)
Chris Wilsone637d2c2017-03-16 13:19:57 +0000271 goto out;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100272
273 total_obj_size = total_gtt_size = count = 0;
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200274 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) {
Chris Wilsone637d2c2017-03-16 13:19:57 +0000275 if (count == total)
276 break;
277
Chris Wilson6d2b88852013-08-07 18:30:54 +0100278 if (obj->stolen == NULL)
279 continue;
280
Chris Wilsone637d2c2017-03-16 13:19:57 +0000281 objects[count++] = obj;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100282 total_obj_size += obj->base.size;
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100283 total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
Chris Wilsone637d2c2017-03-16 13:19:57 +0000284
Chris Wilson6d2b88852013-08-07 18:30:54 +0100285 }
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200286 list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_link) {
Chris Wilsone637d2c2017-03-16 13:19:57 +0000287 if (count == total)
288 break;
289
Chris Wilson6d2b88852013-08-07 18:30:54 +0100290 if (obj->stolen == NULL)
291 continue;
292
Chris Wilsone637d2c2017-03-16 13:19:57 +0000293 objects[count++] = obj;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100294 total_obj_size += obj->base.size;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100295 }
Chris Wilson6d2b88852013-08-07 18:30:54 +0100296
Chris Wilsone637d2c2017-03-16 13:19:57 +0000297 sort(objects, count, sizeof(*objects), obj_rank_by_stolen, NULL);
298
299 seq_puts(m, "Stolen:\n");
300 for (n = 0; n < count; n++) {
301 seq_puts(m, " ");
302 describe_obj(m, objects[n]);
303 seq_putc(m, '\n');
304 }
305 seq_printf(m, "Total %lu objects, %llu bytes, %llu GTT size\n",
Chris Wilson6d2b88852013-08-07 18:30:54 +0100306 count, total_obj_size, total_gtt_size);
Chris Wilsone637d2c2017-03-16 13:19:57 +0000307
308 mutex_unlock(&dev->struct_mutex);
309out:
Michal Hocko20981052017-05-17 14:23:12 +0200310 kvfree(objects);
Chris Wilsone637d2c2017-03-16 13:19:57 +0000311 return ret;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100312}
313
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100314struct file_stats {
Chris Wilson6313c202014-03-19 13:45:45 +0000315 struct drm_i915_file_private *file_priv;
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300316 unsigned long count;
317 u64 total, unbound;
318 u64 global, shared;
319 u64 active, inactive;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100320};
321
322static int per_file_stats(int id, void *ptr, void *data)
323{
324 struct drm_i915_gem_object *obj = ptr;
325 struct file_stats *stats = data;
Chris Wilson6313c202014-03-19 13:45:45 +0000326 struct i915_vma *vma;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100327
Chris Wilson0caf81b2017-06-17 12:57:44 +0100328 lockdep_assert_held(&obj->base.dev->struct_mutex);
329
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100330 stats->count++;
331 stats->total += obj->base.size;
Chris Wilson15717de2016-08-04 07:52:26 +0100332 if (!obj->bind_count)
333 stats->unbound += obj->base.size;
Chris Wilsonc67a17e2014-03-19 13:45:46 +0000334 if (obj->base.name || obj->base.dma_buf)
335 stats->shared += obj->base.size;
336
Chris Wilson894eeec2016-08-04 07:52:20 +0100337 list_for_each_entry(vma, &obj->vma_list, obj_link) {
338 if (!drm_mm_node_allocated(&vma->node))
339 continue;
Chris Wilson6313c202014-03-19 13:45:45 +0000340
Chris Wilson3272db52016-08-04 16:32:32 +0100341 if (i915_vma_is_ggtt(vma)) {
Chris Wilson894eeec2016-08-04 07:52:20 +0100342 stats->global += vma->node.size;
343 } else {
344 struct i915_hw_ppgtt *ppgtt = i915_vm_to_ppgtt(vma->vm);
Chris Wilson6313c202014-03-19 13:45:45 +0000345
Chris Wilson2bfa9962016-08-04 07:52:25 +0100346 if (ppgtt->base.file != stats->file_priv)
Chris Wilson6313c202014-03-19 13:45:45 +0000347 continue;
Chris Wilson6313c202014-03-19 13:45:45 +0000348 }
Chris Wilson894eeec2016-08-04 07:52:20 +0100349
Chris Wilsonb0decaf2016-08-04 07:52:44 +0100350 if (i915_vma_is_active(vma))
Chris Wilson894eeec2016-08-04 07:52:20 +0100351 stats->active += vma->node.size;
352 else
353 stats->inactive += vma->node.size;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100354 }
355
356 return 0;
357}
358
Chris Wilsonb0da1b72015-04-07 16:20:40 +0100359#define print_file_stats(m, name, stats) do { \
360 if (stats.count) \
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300361 seq_printf(m, "%s: %lu objects, %llu bytes (%llu active, %llu inactive, %llu global, %llu shared, %llu unbound)\n", \
Chris Wilsonb0da1b72015-04-07 16:20:40 +0100362 name, \
363 stats.count, \
364 stats.total, \
365 stats.active, \
366 stats.inactive, \
367 stats.global, \
368 stats.shared, \
369 stats.unbound); \
370} while (0)
Brad Volkin493018d2014-12-11 12:13:08 -0800371
372static void print_batch_pool_stats(struct seq_file *m,
373 struct drm_i915_private *dev_priv)
374{
375 struct drm_i915_gem_object *obj;
376 struct file_stats stats;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000377 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530378 enum intel_engine_id id;
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000379 int j;
Brad Volkin493018d2014-12-11 12:13:08 -0800380
381 memset(&stats, 0, sizeof(stats));
382
Akash Goel3b3f1652016-10-13 22:44:48 +0530383 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000384 for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) {
Chris Wilson8d9d5742015-04-07 16:20:38 +0100385 list_for_each_entry(obj,
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000386 &engine->batch_pool.cache_list[j],
Chris Wilson8d9d5742015-04-07 16:20:38 +0100387 batch_pool_link)
388 per_file_stats(0, obj, &stats);
389 }
Chris Wilson06fbca72015-04-07 16:20:36 +0100390 }
Brad Volkin493018d2014-12-11 12:13:08 -0800391
Chris Wilsonb0da1b72015-04-07 16:20:40 +0100392 print_file_stats(m, "[k]batch pool", stats);
Brad Volkin493018d2014-12-11 12:13:08 -0800393}
394
Chris Wilson15da9562016-05-24 14:53:43 +0100395static int per_file_ctx_stats(int id, void *ptr, void *data)
396{
397 struct i915_gem_context *ctx = ptr;
398 int n;
399
400 for (n = 0; n < ARRAY_SIZE(ctx->engine); n++) {
401 if (ctx->engine[n].state)
Chris Wilsonbf3783e2016-08-15 10:48:54 +0100402 per_file_stats(0, ctx->engine[n].state->obj, data);
Chris Wilsondca33ec2016-08-02 22:50:20 +0100403 if (ctx->engine[n].ring)
Chris Wilson57e88532016-08-15 10:48:57 +0100404 per_file_stats(0, ctx->engine[n].ring->vma->obj, data);
Chris Wilson15da9562016-05-24 14:53:43 +0100405 }
406
407 return 0;
408}
409
410static void print_context_stats(struct seq_file *m,
411 struct drm_i915_private *dev_priv)
412{
David Weinehall36cdd012016-08-22 13:59:31 +0300413 struct drm_device *dev = &dev_priv->drm;
Chris Wilson15da9562016-05-24 14:53:43 +0100414 struct file_stats stats;
415 struct drm_file *file;
416
417 memset(&stats, 0, sizeof(stats));
418
David Weinehall36cdd012016-08-22 13:59:31 +0300419 mutex_lock(&dev->struct_mutex);
Chris Wilson15da9562016-05-24 14:53:43 +0100420 if (dev_priv->kernel_context)
421 per_file_ctx_stats(0, dev_priv->kernel_context, &stats);
422
David Weinehall36cdd012016-08-22 13:59:31 +0300423 list_for_each_entry(file, &dev->filelist, lhead) {
Chris Wilson15da9562016-05-24 14:53:43 +0100424 struct drm_i915_file_private *fpriv = file->driver_priv;
425 idr_for_each(&fpriv->context_idr, per_file_ctx_stats, &stats);
426 }
David Weinehall36cdd012016-08-22 13:59:31 +0300427 mutex_unlock(&dev->struct_mutex);
Chris Wilson15da9562016-05-24 14:53:43 +0100428
429 print_file_stats(m, "[k]contexts", stats);
430}
431
David Weinehall36cdd012016-08-22 13:59:31 +0300432static int i915_gem_object_info(struct seq_file *m, void *data)
Chris Wilson73aa8082010-09-30 11:46:12 +0100433{
David Weinehall36cdd012016-08-22 13:59:31 +0300434 struct drm_i915_private *dev_priv = node_to_i915(m->private);
435 struct drm_device *dev = &dev_priv->drm;
Joonas Lahtinen72e96d62016-03-30 16:57:10 +0300436 struct i915_ggtt *ggtt = &dev_priv->ggtt;
Matthew Auld7393b7e2017-10-06 23:18:28 +0100437 u32 count, mapped_count, purgeable_count, dpy_count, huge_count;
438 u64 size, mapped_size, purgeable_size, dpy_size, huge_size;
Chris Wilson6299f992010-11-24 12:23:44 +0000439 struct drm_i915_gem_object *obj;
Matthew Auld7393b7e2017-10-06 23:18:28 +0100440 unsigned int page_sizes = 0;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100441 struct drm_file *file;
Matthew Auld7393b7e2017-10-06 23:18:28 +0100442 char buf[80];
Chris Wilson73aa8082010-09-30 11:46:12 +0100443 int ret;
444
445 ret = mutex_lock_interruptible(&dev->struct_mutex);
446 if (ret)
447 return ret;
448
Chris Wilson3ef7f222016-10-18 13:02:48 +0100449 seq_printf(m, "%u objects, %llu bytes\n",
Chris Wilson6299f992010-11-24 12:23:44 +0000450 dev_priv->mm.object_count,
451 dev_priv->mm.object_memory);
452
Chris Wilson1544c422016-08-15 13:18:16 +0100453 size = count = 0;
454 mapped_size = mapped_count = 0;
455 purgeable_size = purgeable_count = 0;
Matthew Auld7393b7e2017-10-06 23:18:28 +0100456 huge_size = huge_count = 0;
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200457 list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_link) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100458 size += obj->base.size;
459 ++count;
Chris Wilson6c085a72012-08-20 11:40:46 +0200460
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100461 if (obj->mm.madv == I915_MADV_DONTNEED) {
Chris Wilsonb7abb712012-08-20 11:33:30 +0200462 purgeable_size += obj->base.size;
463 ++purgeable_count;
464 }
Chris Wilson2bd160a2016-08-15 10:48:45 +0100465
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100466 if (obj->mm.mapping) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100467 mapped_count++;
468 mapped_size += obj->base.size;
Tvrtko Ursulinbe19b102016-04-15 11:34:53 +0100469 }
Matthew Auld7393b7e2017-10-06 23:18:28 +0100470
471 if (obj->mm.page_sizes.sg > I915_GTT_PAGE_SIZE) {
472 huge_count++;
473 huge_size += obj->base.size;
474 page_sizes |= obj->mm.page_sizes.sg;
475 }
Chris Wilson6299f992010-11-24 12:23:44 +0000476 }
Chris Wilson2bd160a2016-08-15 10:48:45 +0100477 seq_printf(m, "%u unbound objects, %llu bytes\n", count, size);
478
479 size = count = dpy_size = dpy_count = 0;
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200480 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100481 size += obj->base.size;
482 ++count;
483
484 if (obj->pin_display) {
485 dpy_size += obj->base.size;
486 ++dpy_count;
487 }
488
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100489 if (obj->mm.madv == I915_MADV_DONTNEED) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100490 purgeable_size += obj->base.size;
491 ++purgeable_count;
492 }
493
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100494 if (obj->mm.mapping) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100495 mapped_count++;
496 mapped_size += obj->base.size;
497 }
Matthew Auld7393b7e2017-10-06 23:18:28 +0100498
499 if (obj->mm.page_sizes.sg > I915_GTT_PAGE_SIZE) {
500 huge_count++;
501 huge_size += obj->base.size;
502 page_sizes |= obj->mm.page_sizes.sg;
503 }
Chris Wilson2bd160a2016-08-15 10:48:45 +0100504 }
505 seq_printf(m, "%u bound objects, %llu bytes\n",
506 count, size);
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300507 seq_printf(m, "%u purgeable objects, %llu bytes\n",
Chris Wilsonb7abb712012-08-20 11:33:30 +0200508 purgeable_count, purgeable_size);
Chris Wilson2bd160a2016-08-15 10:48:45 +0100509 seq_printf(m, "%u mapped objects, %llu bytes\n",
510 mapped_count, mapped_size);
Matthew Auld7393b7e2017-10-06 23:18:28 +0100511 seq_printf(m, "%u huge-paged objects (%s) %llu bytes\n",
512 huge_count,
513 stringify_page_sizes(page_sizes, buf, sizeof(buf)),
514 huge_size);
Chris Wilson2bd160a2016-08-15 10:48:45 +0100515 seq_printf(m, "%u display objects (pinned), %llu bytes\n",
516 dpy_count, dpy_size);
Chris Wilson6299f992010-11-24 12:23:44 +0000517
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300518 seq_printf(m, "%llu [%llu] gtt total\n",
Chris Wilson381b9432017-02-15 08:43:54 +0000519 ggtt->base.total, ggtt->mappable_end);
Matthew Auld7393b7e2017-10-06 23:18:28 +0100520 seq_printf(m, "Supported page sizes: %s\n",
521 stringify_page_sizes(INTEL_INFO(dev_priv)->page_sizes,
522 buf, sizeof(buf)));
Chris Wilson73aa8082010-09-30 11:46:12 +0100523
Damien Lespiau267f0c92013-06-24 22:59:48 +0100524 seq_putc(m, '\n');
Brad Volkin493018d2014-12-11 12:13:08 -0800525 print_batch_pool_stats(m, dev_priv);
Daniel Vetter1d2ac402016-04-26 19:29:41 +0200526 mutex_unlock(&dev->struct_mutex);
527
528 mutex_lock(&dev->filelist_mutex);
Chris Wilson15da9562016-05-24 14:53:43 +0100529 print_context_stats(m, dev_priv);
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100530 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
531 struct file_stats stats;
Chris Wilsonc84455b2016-08-15 10:49:08 +0100532 struct drm_i915_file_private *file_priv = file->driver_priv;
533 struct drm_i915_gem_request *request;
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900534 struct task_struct *task;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100535
Chris Wilson0caf81b2017-06-17 12:57:44 +0100536 mutex_lock(&dev->struct_mutex);
537
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100538 memset(&stats, 0, sizeof(stats));
Chris Wilson6313c202014-03-19 13:45:45 +0000539 stats.file_priv = file->driver_priv;
Chris Wilson5b5ffff2014-06-17 09:56:24 +0100540 spin_lock(&file->table_lock);
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100541 idr_for_each(&file->object_idr, per_file_stats, &stats);
Chris Wilson5b5ffff2014-06-17 09:56:24 +0100542 spin_unlock(&file->table_lock);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900543 /*
544 * Although we have a valid reference on file->pid, that does
545 * not guarantee that the task_struct who called get_pid() is
546 * still alive (e.g. get_pid(current) => fork() => exit()).
547 * Therefore, we need to protect this ->comm access using RCU.
548 */
Chris Wilsonc84455b2016-08-15 10:49:08 +0100549 request = list_first_entry_or_null(&file_priv->mm.request_list,
550 struct drm_i915_gem_request,
Chris Wilsonc8659ef2017-03-02 12:25:25 +0000551 client_link);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900552 rcu_read_lock();
Chris Wilsonc84455b2016-08-15 10:49:08 +0100553 task = pid_task(request && request->ctx->pid ?
554 request->ctx->pid : file->pid,
555 PIDTYPE_PID);
Brad Volkin493018d2014-12-11 12:13:08 -0800556 print_file_stats(m, task ? task->comm : "<unknown>", stats);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900557 rcu_read_unlock();
Chris Wilson0caf81b2017-06-17 12:57:44 +0100558
Chris Wilsonc84455b2016-08-15 10:49:08 +0100559 mutex_unlock(&dev->struct_mutex);
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100560 }
Daniel Vetter1d2ac402016-04-26 19:29:41 +0200561 mutex_unlock(&dev->filelist_mutex);
Chris Wilson73aa8082010-09-30 11:46:12 +0100562
563 return 0;
564}
565
Damien Lespiauaee56cf2013-06-24 22:59:49 +0100566static int i915_gem_gtt_info(struct seq_file *m, void *data)
Chris Wilson08c18322011-01-10 00:00:24 +0000567{
Damien Lespiau9f25d002014-05-13 15:30:28 +0100568 struct drm_info_node *node = m->private;
David Weinehall36cdd012016-08-22 13:59:31 +0300569 struct drm_i915_private *dev_priv = node_to_i915(node);
570 struct drm_device *dev = &dev_priv->drm;
Chris Wilson5f4b0912016-08-19 12:56:25 +0100571 bool show_pin_display_only = !!node->info_ent->data;
Chris Wilson08c18322011-01-10 00:00:24 +0000572 struct drm_i915_gem_object *obj;
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300573 u64 total_obj_size, total_gtt_size;
Chris Wilson08c18322011-01-10 00:00:24 +0000574 int count, ret;
575
576 ret = mutex_lock_interruptible(&dev->struct_mutex);
577 if (ret)
578 return ret;
579
580 total_obj_size = total_gtt_size = count = 0;
Joonas Lahtinen56cea322016-11-02 12:16:04 +0200581 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) {
Chris Wilson6da84822016-08-15 10:48:44 +0100582 if (show_pin_display_only && !obj->pin_display)
Chris Wilson1b502472012-04-24 15:47:30 +0100583 continue;
584
Damien Lespiau267f0c92013-06-24 22:59:48 +0100585 seq_puts(m, " ");
Chris Wilson08c18322011-01-10 00:00:24 +0000586 describe_obj(m, obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +0100587 seq_putc(m, '\n');
Chris Wilson08c18322011-01-10 00:00:24 +0000588 total_obj_size += obj->base.size;
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100589 total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
Chris Wilson08c18322011-01-10 00:00:24 +0000590 count++;
591 }
592
593 mutex_unlock(&dev->struct_mutex);
594
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300595 seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n",
Chris Wilson08c18322011-01-10 00:00:24 +0000596 count, total_obj_size, total_gtt_size);
597
598 return 0;
599}
600
Brad Volkin493018d2014-12-11 12:13:08 -0800601static int i915_gem_batch_pool_info(struct seq_file *m, void *data)
602{
David Weinehall36cdd012016-08-22 13:59:31 +0300603 struct drm_i915_private *dev_priv = node_to_i915(m->private);
604 struct drm_device *dev = &dev_priv->drm;
Brad Volkin493018d2014-12-11 12:13:08 -0800605 struct drm_i915_gem_object *obj;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000606 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530607 enum intel_engine_id id;
Chris Wilson8d9d5742015-04-07 16:20:38 +0100608 int total = 0;
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000609 int ret, j;
Brad Volkin493018d2014-12-11 12:13:08 -0800610
611 ret = mutex_lock_interruptible(&dev->struct_mutex);
612 if (ret)
613 return ret;
614
Akash Goel3b3f1652016-10-13 22:44:48 +0530615 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000616 for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) {
Chris Wilson8d9d5742015-04-07 16:20:38 +0100617 int count;
618
619 count = 0;
620 list_for_each_entry(obj,
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000621 &engine->batch_pool.cache_list[j],
Chris Wilson8d9d5742015-04-07 16:20:38 +0100622 batch_pool_link)
623 count++;
624 seq_printf(m, "%s cache[%d]: %d objects\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000625 engine->name, j, count);
Chris Wilson8d9d5742015-04-07 16:20:38 +0100626
627 list_for_each_entry(obj,
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000628 &engine->batch_pool.cache_list[j],
Chris Wilson8d9d5742015-04-07 16:20:38 +0100629 batch_pool_link) {
630 seq_puts(m, " ");
631 describe_obj(m, obj);
632 seq_putc(m, '\n');
633 }
634
635 total += count;
Chris Wilson06fbca72015-04-07 16:20:36 +0100636 }
Brad Volkin493018d2014-12-11 12:13:08 -0800637 }
638
Chris Wilson8d9d5742015-04-07 16:20:38 +0100639 seq_printf(m, "total: %d\n", total);
Brad Volkin493018d2014-12-11 12:13:08 -0800640
641 mutex_unlock(&dev->struct_mutex);
642
643 return 0;
644}
645
Chris Wilson1b365952016-10-04 21:11:31 +0100646static void print_request(struct seq_file *m,
647 struct drm_i915_gem_request *rq,
648 const char *prefix)
649{
Chris Wilson20311bd2016-11-14 20:41:03 +0000650 seq_printf(m, "%s%x [%x:%x] prio=%d @ %dms: %s\n", prefix,
Chris Wilson65e47602016-10-28 13:58:49 +0100651 rq->global_seqno, rq->ctx->hw_id, rq->fence.seqno,
Chris Wilson20311bd2016-11-14 20:41:03 +0000652 rq->priotree.priority,
Chris Wilson1b365952016-10-04 21:11:31 +0100653 jiffies_to_msecs(jiffies - rq->emitted_jiffies),
Chris Wilson562f5d42016-10-28 13:58:54 +0100654 rq->timeline->common->name);
Chris Wilson1b365952016-10-04 21:11:31 +0100655}
656
Ben Gamari20172632009-02-17 20:08:50 -0500657static int i915_gem_request_info(struct seq_file *m, void *data)
658{
David Weinehall36cdd012016-08-22 13:59:31 +0300659 struct drm_i915_private *dev_priv = node_to_i915(m->private);
660 struct drm_device *dev = &dev_priv->drm;
Daniel Vettereed29a52015-05-21 14:21:25 +0200661 struct drm_i915_gem_request *req;
Akash Goel3b3f1652016-10-13 22:44:48 +0530662 struct intel_engine_cs *engine;
663 enum intel_engine_id id;
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000664 int ret, any;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100665
666 ret = mutex_lock_interruptible(&dev->struct_mutex);
667 if (ret)
668 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500669
Chris Wilson2d1070b2015-04-01 10:36:56 +0100670 any = 0;
Akash Goel3b3f1652016-10-13 22:44:48 +0530671 for_each_engine(engine, dev_priv, id) {
Chris Wilson2d1070b2015-04-01 10:36:56 +0100672 int count;
673
674 count = 0;
Chris Wilson73cb9702016-10-28 13:58:46 +0100675 list_for_each_entry(req, &engine->timeline->requests, link)
Chris Wilson2d1070b2015-04-01 10:36:56 +0100676 count++;
677 if (count == 0)
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100678 continue;
679
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000680 seq_printf(m, "%s requests: %d\n", engine->name, count);
Chris Wilson73cb9702016-10-28 13:58:46 +0100681 list_for_each_entry(req, &engine->timeline->requests, link)
Chris Wilson1b365952016-10-04 21:11:31 +0100682 print_request(m, req, " ");
Chris Wilson2d1070b2015-04-01 10:36:56 +0100683
684 any++;
Ben Gamari20172632009-02-17 20:08:50 -0500685 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100686 mutex_unlock(&dev->struct_mutex);
687
Chris Wilson2d1070b2015-04-01 10:36:56 +0100688 if (any == 0)
Damien Lespiau267f0c92013-06-24 22:59:48 +0100689 seq_puts(m, "No requests\n");
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100690
Ben Gamari20172632009-02-17 20:08:50 -0500691 return 0;
692}
693
Chris Wilsonb2223492010-10-27 15:27:33 +0100694static void i915_ring_seqno_info(struct seq_file *m,
Tvrtko Ursulin0bc40be2016-03-16 11:00:37 +0000695 struct intel_engine_cs *engine)
Chris Wilsonb2223492010-10-27 15:27:33 +0100696{
Chris Wilson688e6c72016-07-01 17:23:15 +0100697 struct intel_breadcrumbs *b = &engine->breadcrumbs;
698 struct rb_node *rb;
699
Chris Wilson12471ba2016-04-09 10:57:55 +0100700 seq_printf(m, "Current sequence (%s): %x\n",
Chris Wilson1b7744e2016-07-01 17:23:17 +0100701 engine->name, intel_engine_get_seqno(engine));
Chris Wilson688e6c72016-07-01 17:23:15 +0100702
Chris Wilson61d3dc72017-03-03 19:08:24 +0000703 spin_lock_irq(&b->rb_lock);
Chris Wilson688e6c72016-07-01 17:23:15 +0100704 for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) {
Geliang Tangf802cf72016-12-19 22:43:49 +0800705 struct intel_wait *w = rb_entry(rb, typeof(*w), node);
Chris Wilson688e6c72016-07-01 17:23:15 +0100706
707 seq_printf(m, "Waiting (%s): %s [%d] on %x\n",
708 engine->name, w->tsk->comm, w->tsk->pid, w->seqno);
709 }
Chris Wilson61d3dc72017-03-03 19:08:24 +0000710 spin_unlock_irq(&b->rb_lock);
Chris Wilsonb2223492010-10-27 15:27:33 +0100711}
712
Ben Gamari20172632009-02-17 20:08:50 -0500713static int i915_gem_seqno_info(struct seq_file *m, void *data)
714{
David Weinehall36cdd012016-08-22 13:59:31 +0300715 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000716 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530717 enum intel_engine_id id;
Ben Gamari20172632009-02-17 20:08:50 -0500718
Akash Goel3b3f1652016-10-13 22:44:48 +0530719 for_each_engine(engine, dev_priv, id)
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000720 i915_ring_seqno_info(m, engine);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100721
Ben Gamari20172632009-02-17 20:08:50 -0500722 return 0;
723}
724
725
726static int i915_interrupt_info(struct seq_file *m, void *data)
727{
David Weinehall36cdd012016-08-22 13:59:31 +0300728 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000729 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530730 enum intel_engine_id id;
Chris Wilson4bb05042016-09-03 07:53:43 +0100731 int i, pipe;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100732
Paulo Zanonic8c8fb32013-11-27 18:21:54 -0200733 intel_runtime_pm_get(dev_priv);
Ben Gamari20172632009-02-17 20:08:50 -0500734
David Weinehall36cdd012016-08-22 13:59:31 +0300735 if (IS_CHERRYVIEW(dev_priv)) {
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300736 seq_printf(m, "Master Interrupt Control:\t%08x\n",
737 I915_READ(GEN8_MASTER_IRQ));
738
739 seq_printf(m, "Display IER:\t%08x\n",
740 I915_READ(VLV_IER));
741 seq_printf(m, "Display IIR:\t%08x\n",
742 I915_READ(VLV_IIR));
743 seq_printf(m, "Display IIR_RW:\t%08x\n",
744 I915_READ(VLV_IIR_RW));
745 seq_printf(m, "Display IMR:\t%08x\n",
746 I915_READ(VLV_IMR));
Chris Wilson9c870d02016-10-24 13:42:15 +0100747 for_each_pipe(dev_priv, pipe) {
748 enum intel_display_power_domain power_domain;
749
750 power_domain = POWER_DOMAIN_PIPE(pipe);
751 if (!intel_display_power_get_if_enabled(dev_priv,
752 power_domain)) {
753 seq_printf(m, "Pipe %c power disabled\n",
754 pipe_name(pipe));
755 continue;
756 }
757
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300758 seq_printf(m, "Pipe %c stat:\t%08x\n",
759 pipe_name(pipe),
760 I915_READ(PIPESTAT(pipe)));
761
Chris Wilson9c870d02016-10-24 13:42:15 +0100762 intel_display_power_put(dev_priv, power_domain);
763 }
764
765 intel_display_power_get(dev_priv, POWER_DOMAIN_INIT);
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300766 seq_printf(m, "Port hotplug:\t%08x\n",
767 I915_READ(PORT_HOTPLUG_EN));
768 seq_printf(m, "DPFLIPSTAT:\t%08x\n",
769 I915_READ(VLV_DPFLIPSTAT));
770 seq_printf(m, "DPINVGTT:\t%08x\n",
771 I915_READ(DPINVGTT));
Chris Wilson9c870d02016-10-24 13:42:15 +0100772 intel_display_power_put(dev_priv, POWER_DOMAIN_INIT);
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300773
774 for (i = 0; i < 4; i++) {
775 seq_printf(m, "GT Interrupt IMR %d:\t%08x\n",
776 i, I915_READ(GEN8_GT_IMR(i)));
777 seq_printf(m, "GT Interrupt IIR %d:\t%08x\n",
778 i, I915_READ(GEN8_GT_IIR(i)));
779 seq_printf(m, "GT Interrupt IER %d:\t%08x\n",
780 i, I915_READ(GEN8_GT_IER(i)));
781 }
782
783 seq_printf(m, "PCU interrupt mask:\t%08x\n",
784 I915_READ(GEN8_PCU_IMR));
785 seq_printf(m, "PCU interrupt identity:\t%08x\n",
786 I915_READ(GEN8_PCU_IIR));
787 seq_printf(m, "PCU interrupt enable:\t%08x\n",
788 I915_READ(GEN8_PCU_IER));
David Weinehall36cdd012016-08-22 13:59:31 +0300789 } else if (INTEL_GEN(dev_priv) >= 8) {
Ben Widawskya123f152013-11-02 21:07:10 -0700790 seq_printf(m, "Master Interrupt Control:\t%08x\n",
791 I915_READ(GEN8_MASTER_IRQ));
792
793 for (i = 0; i < 4; i++) {
794 seq_printf(m, "GT Interrupt IMR %d:\t%08x\n",
795 i, I915_READ(GEN8_GT_IMR(i)));
796 seq_printf(m, "GT Interrupt IIR %d:\t%08x\n",
797 i, I915_READ(GEN8_GT_IIR(i)));
798 seq_printf(m, "GT Interrupt IER %d:\t%08x\n",
799 i, I915_READ(GEN8_GT_IER(i)));
800 }
801
Damien Lespiau055e3932014-08-18 13:49:10 +0100802 for_each_pipe(dev_priv, pipe) {
Imre Deake1296492016-02-12 18:55:17 +0200803 enum intel_display_power_domain power_domain;
804
805 power_domain = POWER_DOMAIN_PIPE(pipe);
806 if (!intel_display_power_get_if_enabled(dev_priv,
807 power_domain)) {
Paulo Zanoni22c59962014-08-08 17:45:32 -0300808 seq_printf(m, "Pipe %c power disabled\n",
809 pipe_name(pipe));
810 continue;
811 }
Ben Widawskya123f152013-11-02 21:07:10 -0700812 seq_printf(m, "Pipe %c IMR:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000813 pipe_name(pipe),
814 I915_READ(GEN8_DE_PIPE_IMR(pipe)));
Ben Widawskya123f152013-11-02 21:07:10 -0700815 seq_printf(m, "Pipe %c IIR:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000816 pipe_name(pipe),
817 I915_READ(GEN8_DE_PIPE_IIR(pipe)));
Ben Widawskya123f152013-11-02 21:07:10 -0700818 seq_printf(m, "Pipe %c IER:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000819 pipe_name(pipe),
820 I915_READ(GEN8_DE_PIPE_IER(pipe)));
Imre Deake1296492016-02-12 18:55:17 +0200821
822 intel_display_power_put(dev_priv, power_domain);
Ben Widawskya123f152013-11-02 21:07:10 -0700823 }
824
825 seq_printf(m, "Display Engine port interrupt mask:\t%08x\n",
826 I915_READ(GEN8_DE_PORT_IMR));
827 seq_printf(m, "Display Engine port interrupt identity:\t%08x\n",
828 I915_READ(GEN8_DE_PORT_IIR));
829 seq_printf(m, "Display Engine port interrupt enable:\t%08x\n",
830 I915_READ(GEN8_DE_PORT_IER));
831
832 seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n",
833 I915_READ(GEN8_DE_MISC_IMR));
834 seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n",
835 I915_READ(GEN8_DE_MISC_IIR));
836 seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n",
837 I915_READ(GEN8_DE_MISC_IER));
838
839 seq_printf(m, "PCU interrupt mask:\t%08x\n",
840 I915_READ(GEN8_PCU_IMR));
841 seq_printf(m, "PCU interrupt identity:\t%08x\n",
842 I915_READ(GEN8_PCU_IIR));
843 seq_printf(m, "PCU interrupt enable:\t%08x\n",
844 I915_READ(GEN8_PCU_IER));
David Weinehall36cdd012016-08-22 13:59:31 +0300845 } else if (IS_VALLEYVIEW(dev_priv)) {
Jesse Barnes7e231dbe2012-03-28 13:39:38 -0700846 seq_printf(m, "Display IER:\t%08x\n",
847 I915_READ(VLV_IER));
848 seq_printf(m, "Display IIR:\t%08x\n",
849 I915_READ(VLV_IIR));
850 seq_printf(m, "Display IIR_RW:\t%08x\n",
851 I915_READ(VLV_IIR_RW));
852 seq_printf(m, "Display IMR:\t%08x\n",
853 I915_READ(VLV_IMR));
Chris Wilson4f4631a2017-02-10 13:36:32 +0000854 for_each_pipe(dev_priv, pipe) {
855 enum intel_display_power_domain power_domain;
856
857 power_domain = POWER_DOMAIN_PIPE(pipe);
858 if (!intel_display_power_get_if_enabled(dev_priv,
859 power_domain)) {
860 seq_printf(m, "Pipe %c power disabled\n",
861 pipe_name(pipe));
862 continue;
863 }
864
Jesse Barnes7e231dbe2012-03-28 13:39:38 -0700865 seq_printf(m, "Pipe %c stat:\t%08x\n",
866 pipe_name(pipe),
867 I915_READ(PIPESTAT(pipe)));
Chris Wilson4f4631a2017-02-10 13:36:32 +0000868 intel_display_power_put(dev_priv, power_domain);
869 }
Jesse Barnes7e231dbe2012-03-28 13:39:38 -0700870
871 seq_printf(m, "Master IER:\t%08x\n",
872 I915_READ(VLV_MASTER_IER));
873
874 seq_printf(m, "Render IER:\t%08x\n",
875 I915_READ(GTIER));
876 seq_printf(m, "Render IIR:\t%08x\n",
877 I915_READ(GTIIR));
878 seq_printf(m, "Render IMR:\t%08x\n",
879 I915_READ(GTIMR));
880
881 seq_printf(m, "PM IER:\t\t%08x\n",
882 I915_READ(GEN6_PMIER));
883 seq_printf(m, "PM IIR:\t\t%08x\n",
884 I915_READ(GEN6_PMIIR));
885 seq_printf(m, "PM IMR:\t\t%08x\n",
886 I915_READ(GEN6_PMIMR));
887
888 seq_printf(m, "Port hotplug:\t%08x\n",
889 I915_READ(PORT_HOTPLUG_EN));
890 seq_printf(m, "DPFLIPSTAT:\t%08x\n",
891 I915_READ(VLV_DPFLIPSTAT));
892 seq_printf(m, "DPINVGTT:\t%08x\n",
893 I915_READ(DPINVGTT));
894
David Weinehall36cdd012016-08-22 13:59:31 +0300895 } else if (!HAS_PCH_SPLIT(dev_priv)) {
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800896 seq_printf(m, "Interrupt enable: %08x\n",
897 I915_READ(IER));
898 seq_printf(m, "Interrupt identity: %08x\n",
899 I915_READ(IIR));
900 seq_printf(m, "Interrupt mask: %08x\n",
901 I915_READ(IMR));
Damien Lespiau055e3932014-08-18 13:49:10 +0100902 for_each_pipe(dev_priv, pipe)
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800903 seq_printf(m, "Pipe %c stat: %08x\n",
904 pipe_name(pipe),
905 I915_READ(PIPESTAT(pipe)));
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800906 } else {
907 seq_printf(m, "North Display Interrupt enable: %08x\n",
908 I915_READ(DEIER));
909 seq_printf(m, "North Display Interrupt identity: %08x\n",
910 I915_READ(DEIIR));
911 seq_printf(m, "North Display Interrupt mask: %08x\n",
912 I915_READ(DEIMR));
913 seq_printf(m, "South Display Interrupt enable: %08x\n",
914 I915_READ(SDEIER));
915 seq_printf(m, "South Display Interrupt identity: %08x\n",
916 I915_READ(SDEIIR));
917 seq_printf(m, "South Display Interrupt mask: %08x\n",
918 I915_READ(SDEIMR));
919 seq_printf(m, "Graphics Interrupt enable: %08x\n",
920 I915_READ(GTIER));
921 seq_printf(m, "Graphics Interrupt identity: %08x\n",
922 I915_READ(GTIIR));
923 seq_printf(m, "Graphics Interrupt mask: %08x\n",
924 I915_READ(GTIMR));
925 }
Akash Goel3b3f1652016-10-13 22:44:48 +0530926 for_each_engine(engine, dev_priv, id) {
David Weinehall36cdd012016-08-22 13:59:31 +0300927 if (INTEL_GEN(dev_priv) >= 6) {
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100928 seq_printf(m,
929 "Graphics Interrupt mask (%s): %08x\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000930 engine->name, I915_READ_IMR(engine));
Chris Wilson9862e602011-01-04 22:22:17 +0000931 }
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000932 i915_ring_seqno_info(m, engine);
Chris Wilson9862e602011-01-04 22:22:17 +0000933 }
Paulo Zanonic8c8fb32013-11-27 18:21:54 -0200934 intel_runtime_pm_put(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100935
Ben Gamari20172632009-02-17 20:08:50 -0500936 return 0;
937}
938
Chris Wilsona6172a82009-02-11 14:26:38 +0000939static int i915_gem_fence_regs_info(struct seq_file *m, void *data)
940{
David Weinehall36cdd012016-08-22 13:59:31 +0300941 struct drm_i915_private *dev_priv = node_to_i915(m->private);
942 struct drm_device *dev = &dev_priv->drm;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100943 int i, ret;
944
945 ret = mutex_lock_interruptible(&dev->struct_mutex);
946 if (ret)
947 return ret;
Chris Wilsona6172a82009-02-11 14:26:38 +0000948
Chris Wilsona6172a82009-02-11 14:26:38 +0000949 seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs);
950 for (i = 0; i < dev_priv->num_fence_regs; i++) {
Chris Wilson49ef5292016-08-18 17:17:00 +0100951 struct i915_vma *vma = dev_priv->fence_regs[i].vma;
Chris Wilsona6172a82009-02-11 14:26:38 +0000952
Chris Wilson6c085a72012-08-20 11:40:46 +0200953 seq_printf(m, "Fence %d, pin count = %d, object = ",
954 i, dev_priv->fence_regs[i].pin_count);
Chris Wilson49ef5292016-08-18 17:17:00 +0100955 if (!vma)
Damien Lespiau267f0c92013-06-24 22:59:48 +0100956 seq_puts(m, "unused");
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100957 else
Chris Wilson49ef5292016-08-18 17:17:00 +0100958 describe_obj(m, vma->obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +0100959 seq_putc(m, '\n');
Chris Wilsona6172a82009-02-11 14:26:38 +0000960 }
961
Chris Wilson05394f32010-11-08 19:18:58 +0000962 mutex_unlock(&dev->struct_mutex);
Chris Wilsona6172a82009-02-11 14:26:38 +0000963 return 0;
964}
965
Chris Wilson98a2f412016-10-12 10:05:18 +0100966#if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR)
Chris Wilson5a4c6f12017-02-14 16:46:11 +0000967static ssize_t gpu_state_read(struct file *file, char __user *ubuf,
968 size_t count, loff_t *pos)
969{
970 struct i915_gpu_state *error = file->private_data;
971 struct drm_i915_error_state_buf str;
972 ssize_t ret;
973 loff_t tmp;
974
975 if (!error)
976 return 0;
977
978 ret = i915_error_state_buf_init(&str, error->i915, count, *pos);
979 if (ret)
980 return ret;
981
982 ret = i915_error_state_to_str(&str, error);
983 if (ret)
984 goto out;
985
986 tmp = 0;
987 ret = simple_read_from_buffer(ubuf, count, &tmp, str.buf, str.bytes);
988 if (ret < 0)
989 goto out;
990
991 *pos = str.start + ret;
992out:
993 i915_error_state_buf_release(&str);
994 return ret;
995}
996
997static int gpu_state_release(struct inode *inode, struct file *file)
998{
999 i915_gpu_state_put(file->private_data);
1000 return 0;
1001}
1002
1003static int i915_gpu_info_open(struct inode *inode, struct file *file)
1004{
Chris Wilson090e5fe2017-03-28 14:14:07 +01001005 struct drm_i915_private *i915 = inode->i_private;
Chris Wilson5a4c6f12017-02-14 16:46:11 +00001006 struct i915_gpu_state *gpu;
1007
Chris Wilson090e5fe2017-03-28 14:14:07 +01001008 intel_runtime_pm_get(i915);
1009 gpu = i915_capture_gpu_state(i915);
1010 intel_runtime_pm_put(i915);
Chris Wilson5a4c6f12017-02-14 16:46:11 +00001011 if (!gpu)
1012 return -ENOMEM;
1013
1014 file->private_data = gpu;
1015 return 0;
1016}
1017
1018static const struct file_operations i915_gpu_info_fops = {
1019 .owner = THIS_MODULE,
1020 .open = i915_gpu_info_open,
1021 .read = gpu_state_read,
1022 .llseek = default_llseek,
1023 .release = gpu_state_release,
1024};
Chris Wilson98a2f412016-10-12 10:05:18 +01001025
Daniel Vetterd5442302012-04-27 15:17:40 +02001026static ssize_t
1027i915_error_state_write(struct file *filp,
1028 const char __user *ubuf,
1029 size_t cnt,
1030 loff_t *ppos)
1031{
Chris Wilson5a4c6f12017-02-14 16:46:11 +00001032 struct i915_gpu_state *error = filp->private_data;
1033
1034 if (!error)
1035 return 0;
Daniel Vetterd5442302012-04-27 15:17:40 +02001036
1037 DRM_DEBUG_DRIVER("Resetting error state\n");
Chris Wilson5a4c6f12017-02-14 16:46:11 +00001038 i915_reset_error_state(error->i915);
Daniel Vetterd5442302012-04-27 15:17:40 +02001039
1040 return cnt;
1041}
1042
1043static int i915_error_state_open(struct inode *inode, struct file *file)
1044{
Chris Wilson5a4c6f12017-02-14 16:46:11 +00001045 file->private_data = i915_first_error_state(inode->i_private);
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001046 return 0;
Daniel Vetterd5442302012-04-27 15:17:40 +02001047}
1048
Daniel Vetterd5442302012-04-27 15:17:40 +02001049static const struct file_operations i915_error_state_fops = {
1050 .owner = THIS_MODULE,
1051 .open = i915_error_state_open,
Chris Wilson5a4c6f12017-02-14 16:46:11 +00001052 .read = gpu_state_read,
Daniel Vetterd5442302012-04-27 15:17:40 +02001053 .write = i915_error_state_write,
1054 .llseek = default_llseek,
Chris Wilson5a4c6f12017-02-14 16:46:11 +00001055 .release = gpu_state_release,
Daniel Vetterd5442302012-04-27 15:17:40 +02001056};
Chris Wilson98a2f412016-10-12 10:05:18 +01001057#endif
1058
Kees Cook647416f2013-03-10 14:10:06 -07001059static int
Kees Cook647416f2013-03-10 14:10:06 -07001060i915_next_seqno_set(void *data, u64 val)
Mika Kuoppala40633212012-12-04 15:12:00 +02001061{
David Weinehall36cdd012016-08-22 13:59:31 +03001062 struct drm_i915_private *dev_priv = data;
1063 struct drm_device *dev = &dev_priv->drm;
Mika Kuoppala40633212012-12-04 15:12:00 +02001064 int ret;
1065
Mika Kuoppala40633212012-12-04 15:12:00 +02001066 ret = mutex_lock_interruptible(&dev->struct_mutex);
1067 if (ret)
1068 return ret;
1069
Chris Wilson73cb9702016-10-28 13:58:46 +01001070 ret = i915_gem_set_global_seqno(dev, val);
Mika Kuoppala40633212012-12-04 15:12:00 +02001071 mutex_unlock(&dev->struct_mutex);
1072
Kees Cook647416f2013-03-10 14:10:06 -07001073 return ret;
Mika Kuoppala40633212012-12-04 15:12:00 +02001074}
1075
Kees Cook647416f2013-03-10 14:10:06 -07001076DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops,
Chris Wilson9b6586a2017-02-23 07:44:08 +00001077 NULL, i915_next_seqno_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03001078 "0x%llx\n");
Mika Kuoppala40633212012-12-04 15:12:00 +02001079
Deepak Sadb4bd12014-03-31 11:30:02 +05301080static int i915_frequency_info(struct seq_file *m, void *unused)
Jesse Barnesf97108d2010-01-29 11:27:07 -08001081{
David Weinehall36cdd012016-08-22 13:59:31 +03001082 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001083 int ret = 0;
1084
1085 intel_runtime_pm_get(dev_priv);
Jesse Barnesf97108d2010-01-29 11:27:07 -08001086
David Weinehall36cdd012016-08-22 13:59:31 +03001087 if (IS_GEN5(dev_priv)) {
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001088 u16 rgvswctl = I915_READ16(MEMSWCTL);
1089 u16 rgvstat = I915_READ16(MEMSTAT_ILK);
1090
1091 seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf);
1092 seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f);
1093 seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >>
1094 MEMSTAT_VID_SHIFT);
1095 seq_printf(m, "Current P-state: %d\n",
1096 (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT);
David Weinehall36cdd012016-08-22 13:59:31 +03001097 } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
Sagar Arun Kamble0d6fc922017-10-10 22:30:02 +01001098 u32 rpmodectl, freq_sts;
Wayne Boyer666a4532015-12-09 12:29:35 -08001099
1100 mutex_lock(&dev_priv->rps.hw_lock);
Sagar Arun Kamble0d6fc922017-10-10 22:30:02 +01001101
1102 rpmodectl = I915_READ(GEN6_RP_CONTROL);
1103 seq_printf(m, "Video Turbo Mode: %s\n",
1104 yesno(rpmodectl & GEN6_RP_MEDIA_TURBO));
1105 seq_printf(m, "HW control enabled: %s\n",
1106 yesno(rpmodectl & GEN6_RP_ENABLE));
1107 seq_printf(m, "SW control enabled: %s\n",
1108 yesno((rpmodectl & GEN6_RP_MEDIA_MODE_MASK) ==
1109 GEN6_RP_MEDIA_SW_MODE));
1110
Wayne Boyer666a4532015-12-09 12:29:35 -08001111 freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
1112 seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts);
1113 seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq);
1114
1115 seq_printf(m, "actual GPU freq: %d MHz\n",
1116 intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff));
1117
1118 seq_printf(m, "current GPU freq: %d MHz\n",
1119 intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq));
1120
1121 seq_printf(m, "max GPU freq: %d MHz\n",
1122 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
1123
1124 seq_printf(m, "min GPU freq: %d MHz\n",
1125 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq));
1126
1127 seq_printf(m, "idle GPU freq: %d MHz\n",
1128 intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq));
1129
1130 seq_printf(m,
1131 "efficient (RPe) frequency: %d MHz\n",
1132 intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq));
1133 mutex_unlock(&dev_priv->rps.hw_lock);
David Weinehall36cdd012016-08-22 13:59:31 +03001134 } else if (INTEL_GEN(dev_priv) >= 6) {
Bob Paauwe35040562015-06-25 14:54:07 -07001135 u32 rp_state_limits;
1136 u32 gt_perf_status;
1137 u32 rp_state_cap;
Chris Wilson0d8f9492014-03-27 09:06:14 +00001138 u32 rpmodectl, rpinclimit, rpdeclimit;
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001139 u32 rpstat, cagf, reqf;
Jesse Barnesccab5c82011-01-18 15:49:25 -08001140 u32 rpupei, rpcurup, rpprevup;
1141 u32 rpdownei, rpcurdown, rpprevdown;
Paulo Zanoni9dd3c602014-08-01 18:14:48 -03001142 u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask;
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001143 int max_freq;
1144
Bob Paauwe35040562015-06-25 14:54:07 -07001145 rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS);
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02001146 if (IS_GEN9_LP(dev_priv)) {
Bob Paauwe35040562015-06-25 14:54:07 -07001147 rp_state_cap = I915_READ(BXT_RP_STATE_CAP);
1148 gt_perf_status = I915_READ(BXT_GT_PERF_STATUS);
1149 } else {
1150 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
1151 gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS);
1152 }
1153
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001154 /* RPSTAT1 is in the GT power well */
Mika Kuoppala59bad942015-01-16 11:34:40 +02001155 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001156
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001157 reqf = I915_READ(GEN6_RPNSWREQ);
Rodrigo Vivi35ceabf2017-07-06 13:41:13 -07001158 if (INTEL_GEN(dev_priv) >= 9)
Akash Goel60260a52015-03-06 11:07:21 +05301159 reqf >>= 23;
1160 else {
1161 reqf &= ~GEN6_TURBO_DISABLE;
David Weinehall36cdd012016-08-22 13:59:31 +03001162 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
Akash Goel60260a52015-03-06 11:07:21 +05301163 reqf >>= 24;
1164 else
1165 reqf >>= 25;
1166 }
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001167 reqf = intel_gpu_freq(dev_priv, reqf);
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001168
Chris Wilson0d8f9492014-03-27 09:06:14 +00001169 rpmodectl = I915_READ(GEN6_RP_CONTROL);
1170 rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD);
1171 rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD);
1172
Jesse Barnesccab5c82011-01-18 15:49:25 -08001173 rpstat = I915_READ(GEN6_RPSTAT1);
Akash Goeld6cda9c2016-04-23 00:05:46 +05301174 rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK;
1175 rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK;
1176 rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK;
1177 rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK;
1178 rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK;
1179 rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK;
Rodrigo Vivi35ceabf2017-07-06 13:41:13 -07001180 if (INTEL_GEN(dev_priv) >= 9)
Akash Goel60260a52015-03-06 11:07:21 +05301181 cagf = (rpstat & GEN9_CAGF_MASK) >> GEN9_CAGF_SHIFT;
David Weinehall36cdd012016-08-22 13:59:31 +03001182 else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
Ben Widawskyf82855d2013-01-29 12:00:15 -08001183 cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT;
1184 else
1185 cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT;
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001186 cagf = intel_gpu_freq(dev_priv, cagf);
Jesse Barnesccab5c82011-01-18 15:49:25 -08001187
Mika Kuoppala59bad942015-01-16 11:34:40 +02001188 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
Ben Widawskyd1ebd8162011-04-25 20:11:50 +01001189
David Weinehall36cdd012016-08-22 13:59:31 +03001190 if (IS_GEN6(dev_priv) || IS_GEN7(dev_priv)) {
Paulo Zanoni9dd3c602014-08-01 18:14:48 -03001191 pm_ier = I915_READ(GEN6_PMIER);
1192 pm_imr = I915_READ(GEN6_PMIMR);
1193 pm_isr = I915_READ(GEN6_PMISR);
1194 pm_iir = I915_READ(GEN6_PMIIR);
1195 pm_mask = I915_READ(GEN6_PMINTRMSK);
1196 } else {
1197 pm_ier = I915_READ(GEN8_GT_IER(2));
1198 pm_imr = I915_READ(GEN8_GT_IMR(2));
1199 pm_isr = I915_READ(GEN8_GT_ISR(2));
1200 pm_iir = I915_READ(GEN8_GT_IIR(2));
1201 pm_mask = I915_READ(GEN6_PMINTRMSK);
1202 }
Sagar Arun Kamble960e5462017-10-10 22:29:59 +01001203 seq_printf(m, "Video Turbo Mode: %s\n",
1204 yesno(rpmodectl & GEN6_RP_MEDIA_TURBO));
1205 seq_printf(m, "HW control enabled: %s\n",
1206 yesno(rpmodectl & GEN6_RP_ENABLE));
1207 seq_printf(m, "SW control enabled: %s\n",
1208 yesno((rpmodectl & GEN6_RP_MEDIA_MODE_MASK) ==
1209 GEN6_RP_MEDIA_SW_MODE));
Chris Wilson0d8f9492014-03-27 09:06:14 +00001210 seq_printf(m, "PM IER=0x%08x IMR=0x%08x ISR=0x%08x IIR=0x%08x, MASK=0x%08x\n",
Paulo Zanoni9dd3c602014-08-01 18:14:48 -03001211 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask);
Sagar Arun Kamble5dd04552017-03-11 08:07:00 +05301212 seq_printf(m, "pm_intrmsk_mbz: 0x%08x\n",
1213 dev_priv->rps.pm_intrmsk_mbz);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001214 seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001215 seq_printf(m, "Render p-state ratio: %d\n",
Rodrigo Vivi35ceabf2017-07-06 13:41:13 -07001216 (gt_perf_status & (INTEL_GEN(dev_priv) >= 9 ? 0x1ff00 : 0xff00)) >> 8);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001217 seq_printf(m, "Render p-state VID: %d\n",
1218 gt_perf_status & 0xff);
1219 seq_printf(m, "Render p-state limit: %d\n",
1220 rp_state_limits & 0xff);
Chris Wilson0d8f9492014-03-27 09:06:14 +00001221 seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat);
1222 seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl);
1223 seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit);
1224 seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit);
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001225 seq_printf(m, "RPNSWREQ: %dMHz\n", reqf);
Ben Widawskyf82855d2013-01-29 12:00:15 -08001226 seq_printf(m, "CAGF: %dMHz\n", cagf);
Akash Goeld6cda9c2016-04-23 00:05:46 +05301227 seq_printf(m, "RP CUR UP EI: %d (%dus)\n",
1228 rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei));
1229 seq_printf(m, "RP CUR UP: %d (%dus)\n",
1230 rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup));
1231 seq_printf(m, "RP PREV UP: %d (%dus)\n",
1232 rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup));
Chris Wilsond86ed342015-04-27 13:41:19 +01001233 seq_printf(m, "Up threshold: %d%%\n",
1234 dev_priv->rps.up_threshold);
1235
Akash Goeld6cda9c2016-04-23 00:05:46 +05301236 seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n",
1237 rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei));
1238 seq_printf(m, "RP CUR DOWN: %d (%dus)\n",
1239 rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown));
1240 seq_printf(m, "RP PREV DOWN: %d (%dus)\n",
1241 rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown));
Chris Wilsond86ed342015-04-27 13:41:19 +01001242 seq_printf(m, "Down threshold: %d%%\n",
1243 dev_priv->rps.down_threshold);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001244
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02001245 max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 0 :
Bob Paauwe35040562015-06-25 14:54:07 -07001246 rp_state_cap >> 16) & 0xff;
Rodrigo Vivi35ceabf2017-07-06 13:41:13 -07001247 max_freq *= (IS_GEN9_BC(dev_priv) ||
1248 IS_CANNONLAKE(dev_priv) ? GEN9_FREQ_SCALER : 1);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001249 seq_printf(m, "Lowest (RPN) frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001250 intel_gpu_freq(dev_priv, max_freq));
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001251
1252 max_freq = (rp_state_cap & 0xff00) >> 8;
Rodrigo Vivi35ceabf2017-07-06 13:41:13 -07001253 max_freq *= (IS_GEN9_BC(dev_priv) ||
1254 IS_CANNONLAKE(dev_priv) ? GEN9_FREQ_SCALER : 1);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001255 seq_printf(m, "Nominal (RP1) frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001256 intel_gpu_freq(dev_priv, max_freq));
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001257
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02001258 max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 16 :
Bob Paauwe35040562015-06-25 14:54:07 -07001259 rp_state_cap >> 0) & 0xff;
Rodrigo Vivi35ceabf2017-07-06 13:41:13 -07001260 max_freq *= (IS_GEN9_BC(dev_priv) ||
1261 IS_CANNONLAKE(dev_priv) ? GEN9_FREQ_SCALER : 1);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001262 seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001263 intel_gpu_freq(dev_priv, max_freq));
Ben Widawsky31c77382013-04-05 14:29:22 -07001264 seq_printf(m, "Max overclocked frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001265 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
Chris Wilsonaed242f2015-03-18 09:48:21 +00001266
Chris Wilsond86ed342015-04-27 13:41:19 +01001267 seq_printf(m, "Current freq: %d MHz\n",
1268 intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq));
1269 seq_printf(m, "Actual freq: %d MHz\n", cagf);
Chris Wilsonaed242f2015-03-18 09:48:21 +00001270 seq_printf(m, "Idle freq: %d MHz\n",
1271 intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq));
Chris Wilsond86ed342015-04-27 13:41:19 +01001272 seq_printf(m, "Min freq: %d MHz\n",
1273 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq));
Chris Wilson29ecd78d2016-07-13 09:10:35 +01001274 seq_printf(m, "Boost freq: %d MHz\n",
1275 intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq));
Chris Wilsond86ed342015-04-27 13:41:19 +01001276 seq_printf(m, "Max freq: %d MHz\n",
1277 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
1278 seq_printf(m,
1279 "efficient (RPe) frequency: %d MHz\n",
1280 intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq));
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001281 } else {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001282 seq_puts(m, "no P-state info available\n");
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001283 }
Jesse Barnesf97108d2010-01-29 11:27:07 -08001284
Ville Syrjälä49cd97a2017-02-07 20:33:45 +02001285 seq_printf(m, "Current CD clock frequency: %d kHz\n", dev_priv->cdclk.hw.cdclk);
Mika Kahola1170f282015-09-25 14:00:32 +03001286 seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq);
1287 seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq);
1288
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001289 intel_runtime_pm_put(dev_priv);
1290 return ret;
Jesse Barnesf97108d2010-01-29 11:27:07 -08001291}
1292
Ben Widawskyd6369512016-09-20 16:54:32 +03001293static void i915_instdone_info(struct drm_i915_private *dev_priv,
1294 struct seq_file *m,
1295 struct intel_instdone *instdone)
1296{
Ben Widawskyf9e61372016-09-20 16:54:33 +03001297 int slice;
1298 int subslice;
1299
Ben Widawskyd6369512016-09-20 16:54:32 +03001300 seq_printf(m, "\t\tINSTDONE: 0x%08x\n",
1301 instdone->instdone);
1302
1303 if (INTEL_GEN(dev_priv) <= 3)
1304 return;
1305
1306 seq_printf(m, "\t\tSC_INSTDONE: 0x%08x\n",
1307 instdone->slice_common);
1308
1309 if (INTEL_GEN(dev_priv) <= 6)
1310 return;
1311
Ben Widawskyf9e61372016-09-20 16:54:33 +03001312 for_each_instdone_slice_subslice(dev_priv, slice, subslice)
1313 seq_printf(m, "\t\tSAMPLER_INSTDONE[%d][%d]: 0x%08x\n",
1314 slice, subslice, instdone->sampler[slice][subslice]);
1315
1316 for_each_instdone_slice_subslice(dev_priv, slice, subslice)
1317 seq_printf(m, "\t\tROW_INSTDONE[%d][%d]: 0x%08x\n",
1318 slice, subslice, instdone->row[slice][subslice]);
Ben Widawskyd6369512016-09-20 16:54:32 +03001319}
1320
Chris Wilsonf6544492015-01-26 18:03:04 +02001321static int i915_hangcheck_info(struct seq_file *m, void *unused)
1322{
David Weinehall36cdd012016-08-22 13:59:31 +03001323 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001324 struct intel_engine_cs *engine;
Tvrtko Ursulin666796d2016-03-16 11:00:39 +00001325 u64 acthd[I915_NUM_ENGINES];
1326 u32 seqno[I915_NUM_ENGINES];
Ben Widawskyd6369512016-09-20 16:54:32 +03001327 struct intel_instdone instdone;
Dave Gordonc3232b12016-03-23 18:19:53 +00001328 enum intel_engine_id id;
Chris Wilsonf6544492015-01-26 18:03:04 +02001329
Chris Wilson8af29b02016-09-09 14:11:47 +01001330 if (test_bit(I915_WEDGED, &dev_priv->gpu_error.flags))
Chris Wilson8c185ec2017-03-16 17:13:02 +00001331 seq_puts(m, "Wedged\n");
1332 if (test_bit(I915_RESET_BACKOFF, &dev_priv->gpu_error.flags))
1333 seq_puts(m, "Reset in progress: struct_mutex backoff\n");
1334 if (test_bit(I915_RESET_HANDOFF, &dev_priv->gpu_error.flags))
1335 seq_puts(m, "Reset in progress: reset handoff to waiter\n");
Chris Wilson8af29b02016-09-09 14:11:47 +01001336 if (waitqueue_active(&dev_priv->gpu_error.wait_queue))
Chris Wilson8c185ec2017-03-16 17:13:02 +00001337 seq_puts(m, "Waiter holding struct mutex\n");
Chris Wilson8af29b02016-09-09 14:11:47 +01001338 if (waitqueue_active(&dev_priv->gpu_error.reset_queue))
Chris Wilson8c185ec2017-03-16 17:13:02 +00001339 seq_puts(m, "struct_mutex blocked for reset\n");
Chris Wilson8af29b02016-09-09 14:11:47 +01001340
Michal Wajdeczko4f044a82017-09-19 19:38:44 +00001341 if (!i915_modparams.enable_hangcheck) {
Chris Wilson8c185ec2017-03-16 17:13:02 +00001342 seq_puts(m, "Hangcheck disabled\n");
Chris Wilsonf6544492015-01-26 18:03:04 +02001343 return 0;
1344 }
1345
Mika Kuoppalaebbc7542015-02-05 18:41:48 +02001346 intel_runtime_pm_get(dev_priv);
1347
Akash Goel3b3f1652016-10-13 22:44:48 +05301348 for_each_engine(engine, dev_priv, id) {
Chris Wilson7e37f882016-08-02 22:50:21 +01001349 acthd[id] = intel_engine_get_active_head(engine);
Chris Wilson1b7744e2016-07-01 17:23:17 +01001350 seqno[id] = intel_engine_get_seqno(engine);
Mika Kuoppalaebbc7542015-02-05 18:41:48 +02001351 }
1352
Akash Goel3b3f1652016-10-13 22:44:48 +05301353 intel_engine_get_instdone(dev_priv->engine[RCS], &instdone);
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001354
Mika Kuoppalaebbc7542015-02-05 18:41:48 +02001355 intel_runtime_pm_put(dev_priv);
1356
Chris Wilson8352aea2017-03-03 09:00:56 +00001357 if (timer_pending(&dev_priv->gpu_error.hangcheck_work.timer))
1358 seq_printf(m, "Hangcheck active, timer fires in %dms\n",
Chris Wilsonf6544492015-01-26 18:03:04 +02001359 jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires -
1360 jiffies));
Chris Wilson8352aea2017-03-03 09:00:56 +00001361 else if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work))
1362 seq_puts(m, "Hangcheck active, work pending\n");
1363 else
1364 seq_puts(m, "Hangcheck inactive\n");
Chris Wilsonf6544492015-01-26 18:03:04 +02001365
Chris Wilsonf73b5672017-03-02 15:03:56 +00001366 seq_printf(m, "GT active? %s\n", yesno(dev_priv->gt.awake));
1367
Akash Goel3b3f1652016-10-13 22:44:48 +05301368 for_each_engine(engine, dev_priv, id) {
Chris Wilson33f53712016-10-04 21:11:32 +01001369 struct intel_breadcrumbs *b = &engine->breadcrumbs;
1370 struct rb_node *rb;
1371
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001372 seq_printf(m, "%s:\n", engine->name);
Chris Wilsonf73b5672017-03-02 15:03:56 +00001373 seq_printf(m, "\tseqno = %x [current %x, last %x], inflight %d\n",
Chris Wilsoncb399ea2016-11-01 10:03:16 +00001374 engine->hangcheck.seqno, seqno[id],
Chris Wilsonf73b5672017-03-02 15:03:56 +00001375 intel_engine_last_submit(engine),
1376 engine->timeline->inflight_seqnos);
Mika Kuoppala3fe3b032016-11-18 15:09:04 +02001377 seq_printf(m, "\twaiters? %s, fake irq active? %s, stalled? %s\n",
Chris Wilson83348ba2016-08-09 17:47:51 +01001378 yesno(intel_engine_has_waiter(engine)),
1379 yesno(test_bit(engine->id,
Mika Kuoppala3fe3b032016-11-18 15:09:04 +02001380 &dev_priv->gpu_error.missed_irq_rings)),
1381 yesno(engine->hangcheck.stalled));
1382
Chris Wilson61d3dc72017-03-03 19:08:24 +00001383 spin_lock_irq(&b->rb_lock);
Chris Wilson33f53712016-10-04 21:11:32 +01001384 for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) {
Geliang Tangf802cf72016-12-19 22:43:49 +08001385 struct intel_wait *w = rb_entry(rb, typeof(*w), node);
Chris Wilson33f53712016-10-04 21:11:32 +01001386
1387 seq_printf(m, "\t%s [%d] waiting for %x\n",
1388 w->tsk->comm, w->tsk->pid, w->seqno);
1389 }
Chris Wilson61d3dc72017-03-03 19:08:24 +00001390 spin_unlock_irq(&b->rb_lock);
Chris Wilson33f53712016-10-04 21:11:32 +01001391
Chris Wilsonf6544492015-01-26 18:03:04 +02001392 seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001393 (long long)engine->hangcheck.acthd,
Dave Gordonc3232b12016-03-23 18:19:53 +00001394 (long long)acthd[id]);
Mika Kuoppala3fe3b032016-11-18 15:09:04 +02001395 seq_printf(m, "\taction = %s(%d) %d ms ago\n",
1396 hangcheck_action_to_str(engine->hangcheck.action),
1397 engine->hangcheck.action,
1398 jiffies_to_msecs(jiffies -
1399 engine->hangcheck.action_timestamp));
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001400
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001401 if (engine->id == RCS) {
Ben Widawskyd6369512016-09-20 16:54:32 +03001402 seq_puts(m, "\tinstdone read =\n");
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001403
Ben Widawskyd6369512016-09-20 16:54:32 +03001404 i915_instdone_info(dev_priv, m, &instdone);
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001405
Ben Widawskyd6369512016-09-20 16:54:32 +03001406 seq_puts(m, "\tinstdone accu =\n");
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001407
Ben Widawskyd6369512016-09-20 16:54:32 +03001408 i915_instdone_info(dev_priv, m,
1409 &engine->hangcheck.instdone);
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001410 }
Chris Wilsonf6544492015-01-26 18:03:04 +02001411 }
1412
1413 return 0;
1414}
1415
Michel Thierry061d06a2017-06-20 10:57:49 +01001416static int i915_reset_info(struct seq_file *m, void *unused)
1417{
1418 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1419 struct i915_gpu_error *error = &dev_priv->gpu_error;
1420 struct intel_engine_cs *engine;
1421 enum intel_engine_id id;
1422
1423 seq_printf(m, "full gpu reset = %u\n", i915_reset_count(error));
1424
1425 for_each_engine(engine, dev_priv, id) {
1426 seq_printf(m, "%s = %u\n", engine->name,
1427 i915_reset_engine_count(error, engine));
1428 }
1429
1430 return 0;
1431}
1432
Ben Widawsky4d855292011-12-12 19:34:16 -08001433static int ironlake_drpc_info(struct seq_file *m)
Jesse Barnesf97108d2010-01-29 11:27:07 -08001434{
David Weinehall36cdd012016-08-22 13:59:31 +03001435 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Ben Widawsky616fdb52011-10-05 11:44:54 -07001436 u32 rgvmodectl, rstdbyctl;
1437 u16 crstandvid;
Ben Widawsky616fdb52011-10-05 11:44:54 -07001438
Ben Widawsky616fdb52011-10-05 11:44:54 -07001439 rgvmodectl = I915_READ(MEMMODECTL);
1440 rstdbyctl = I915_READ(RSTDBYCTL);
1441 crstandvid = I915_READ16(CRSTANDVID);
1442
Jani Nikula742f4912015-09-03 11:16:09 +03001443 seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001444 seq_printf(m, "Boost freq: %d\n",
1445 (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >>
1446 MEMMODE_BOOST_FREQ_SHIFT);
1447 seq_printf(m, "HW control enabled: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001448 yesno(rgvmodectl & MEMMODE_HWIDLE_EN));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001449 seq_printf(m, "SW control enabled: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001450 yesno(rgvmodectl & MEMMODE_SWMODE_EN));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001451 seq_printf(m, "Gated voltage change: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001452 yesno(rgvmodectl & MEMMODE_RCLK_GATE));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001453 seq_printf(m, "Starting frequency: P%d\n",
1454 (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001455 seq_printf(m, "Max P-state: P%d\n",
Jesse Barnesf97108d2010-01-29 11:27:07 -08001456 (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001457 seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK));
1458 seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f));
1459 seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f));
1460 seq_printf(m, "Render standby enabled: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001461 yesno(!(rstdbyctl & RCX_SW_EXIT)));
Damien Lespiau267f0c92013-06-24 22:59:48 +01001462 seq_puts(m, "Current RS state: ");
Jesse Barnes88271da2011-01-05 12:01:24 -08001463 switch (rstdbyctl & RSX_STATUS_MASK) {
1464 case RSX_STATUS_ON:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001465 seq_puts(m, "on\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001466 break;
1467 case RSX_STATUS_RC1:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001468 seq_puts(m, "RC1\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001469 break;
1470 case RSX_STATUS_RC1E:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001471 seq_puts(m, "RC1E\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001472 break;
1473 case RSX_STATUS_RS1:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001474 seq_puts(m, "RS1\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001475 break;
1476 case RSX_STATUS_RS2:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001477 seq_puts(m, "RS2 (RC6)\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001478 break;
1479 case RSX_STATUS_RS3:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001480 seq_puts(m, "RC3 (RC6+)\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001481 break;
1482 default:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001483 seq_puts(m, "unknown\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001484 break;
1485 }
Jesse Barnesf97108d2010-01-29 11:27:07 -08001486
1487 return 0;
1488}
1489
Mika Kuoppalaf65367b2015-01-16 11:34:42 +02001490static int i915_forcewake_domains(struct seq_file *m, void *data)
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001491{
Chris Wilson233ebf52017-03-23 10:19:44 +00001492 struct drm_i915_private *i915 = node_to_i915(m->private);
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001493 struct intel_uncore_forcewake_domain *fw_domain;
Chris Wilsond2dc94b2017-03-23 10:19:41 +00001494 unsigned int tmp;
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001495
Chris Wilsond7a133d2017-09-07 14:44:41 +01001496 seq_printf(m, "user.bypass_count = %u\n",
1497 i915->uncore.user_forcewake.count);
1498
Chris Wilson233ebf52017-03-23 10:19:44 +00001499 for_each_fw_domain(fw_domain, i915, tmp)
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001500 seq_printf(m, "%s.wake_count = %u\n",
Tvrtko Ursulin33c582c2016-04-07 17:04:33 +01001501 intel_uncore_forcewake_domain_to_str(fw_domain->id),
Chris Wilson233ebf52017-03-23 10:19:44 +00001502 READ_ONCE(fw_domain->wake_count));
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001503
1504 return 0;
1505}
1506
Mika Kuoppala13628772017-03-15 17:43:02 +02001507static void print_rc6_res(struct seq_file *m,
1508 const char *title,
1509 const i915_reg_t reg)
1510{
1511 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1512
1513 seq_printf(m, "%s %u (%llu us)\n",
1514 title, I915_READ(reg),
1515 intel_rc6_residency_us(dev_priv, reg));
1516}
1517
Deepak S669ab5a2014-01-10 15:18:26 +05301518static int vlv_drpc_info(struct seq_file *m)
1519{
David Weinehall36cdd012016-08-22 13:59:31 +03001520 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Sagar Arun Kamble0d6fc922017-10-10 22:30:02 +01001521 u32 rcctl1, pw_status;
Deepak S669ab5a2014-01-10 15:18:26 +05301522
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001523 pw_status = I915_READ(VLV_GTLC_PW_STATUS);
Deepak S669ab5a2014-01-10 15:18:26 +05301524 rcctl1 = I915_READ(GEN6_RC_CONTROL);
1525
Deepak S669ab5a2014-01-10 15:18:26 +05301526 seq_printf(m, "RC6 Enabled: %s\n",
1527 yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE |
1528 GEN6_RC_CTL_EI_MODE(1))));
1529 seq_printf(m, "Render Power Well: %s\n",
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001530 (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down");
Deepak S669ab5a2014-01-10 15:18:26 +05301531 seq_printf(m, "Media Power Well: %s\n",
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001532 (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down");
Deepak S669ab5a2014-01-10 15:18:26 +05301533
Mika Kuoppala13628772017-03-15 17:43:02 +02001534 print_rc6_res(m, "Render RC6 residency since boot:", VLV_GT_RENDER_RC6);
1535 print_rc6_res(m, "Media RC6 residency since boot:", VLV_GT_MEDIA_RC6);
Imre Deak9cc19be2014-04-14 20:24:24 +03001536
Mika Kuoppalaf65367b2015-01-16 11:34:42 +02001537 return i915_forcewake_domains(m, NULL);
Deepak S669ab5a2014-01-10 15:18:26 +05301538}
1539
Ben Widawsky4d855292011-12-12 19:34:16 -08001540static int gen6_drpc_info(struct seq_file *m)
1541{
David Weinehall36cdd012016-08-22 13:59:31 +03001542 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Sagar Arun Kamble960e5462017-10-10 22:29:59 +01001543 u32 gt_core_status, rcctl1, rc6vids = 0;
Akash Goelf2dd7572016-06-27 20:10:01 +05301544 u32 gen9_powergate_enable = 0, gen9_powergate_status = 0;
Daniel Vetter93b525d2012-01-25 13:52:43 +01001545 unsigned forcewake_count;
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001546 int count = 0;
Ben Widawsky4d855292011-12-12 19:34:16 -08001547
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001548 forcewake_count = READ_ONCE(dev_priv->uncore.fw_domain[FW_DOMAIN_ID_RENDER].wake_count);
Daniel Vetter93b525d2012-01-25 13:52:43 +01001549 if (forcewake_count) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001550 seq_puts(m, "RC information inaccurate because somebody "
1551 "holds a forcewake reference \n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001552 } else {
1553 /* NB: we cannot use forcewake, else we read the wrong values */
1554 while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1))
1555 udelay(10);
1556 seq_printf(m, "RC information accurate: %s\n", yesno(count < 51));
1557 }
1558
Ville Syrjälä75aa3f62015-10-22 15:34:56 +03001559 gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS);
Chris Wilsoned71f1b2013-07-19 20:36:56 +01001560 trace_i915_reg_rw(false, GEN6_GT_CORE_STATUS, gt_core_status, 4, true);
Ben Widawsky4d855292011-12-12 19:34:16 -08001561
Ben Widawsky4d855292011-12-12 19:34:16 -08001562 rcctl1 = I915_READ(GEN6_RC_CONTROL);
David Weinehall36cdd012016-08-22 13:59:31 +03001563 if (INTEL_GEN(dev_priv) >= 9) {
Akash Goelf2dd7572016-06-27 20:10:01 +05301564 gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE);
1565 gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS);
1566 }
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001567
Ben Widawsky44cbd332012-11-06 14:36:36 +00001568 mutex_lock(&dev_priv->rps.hw_lock);
1569 sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids);
1570 mutex_unlock(&dev_priv->rps.hw_lock);
Ben Widawsky4d855292011-12-12 19:34:16 -08001571
Eric Anholtfff24e22012-01-23 16:14:05 -08001572 seq_printf(m, "RC1e Enabled: %s\n",
Ben Widawsky4d855292011-12-12 19:34:16 -08001573 yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE));
1574 seq_printf(m, "RC6 Enabled: %s\n",
1575 yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE));
David Weinehall36cdd012016-08-22 13:59:31 +03001576 if (INTEL_GEN(dev_priv) >= 9) {
Akash Goelf2dd7572016-06-27 20:10:01 +05301577 seq_printf(m, "Render Well Gating Enabled: %s\n",
1578 yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE));
1579 seq_printf(m, "Media Well Gating Enabled: %s\n",
1580 yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE));
1581 }
Ben Widawsky4d855292011-12-12 19:34:16 -08001582 seq_printf(m, "Deep RC6 Enabled: %s\n",
1583 yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE));
1584 seq_printf(m, "Deepest RC6 Enabled: %s\n",
1585 yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE));
Damien Lespiau267f0c92013-06-24 22:59:48 +01001586 seq_puts(m, "Current RC state: ");
Ben Widawsky4d855292011-12-12 19:34:16 -08001587 switch (gt_core_status & GEN6_RCn_MASK) {
1588 case GEN6_RC0:
1589 if (gt_core_status & GEN6_CORE_CPD_STATE_MASK)
Damien Lespiau267f0c92013-06-24 22:59:48 +01001590 seq_puts(m, "Core Power Down\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001591 else
Damien Lespiau267f0c92013-06-24 22:59:48 +01001592 seq_puts(m, "on\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001593 break;
1594 case GEN6_RC3:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001595 seq_puts(m, "RC3\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001596 break;
1597 case GEN6_RC6:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001598 seq_puts(m, "RC6\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001599 break;
1600 case GEN6_RC7:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001601 seq_puts(m, "RC7\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001602 break;
1603 default:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001604 seq_puts(m, "Unknown\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001605 break;
1606 }
1607
1608 seq_printf(m, "Core Power Down: %s\n",
1609 yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK));
David Weinehall36cdd012016-08-22 13:59:31 +03001610 if (INTEL_GEN(dev_priv) >= 9) {
Akash Goelf2dd7572016-06-27 20:10:01 +05301611 seq_printf(m, "Render Power Well: %s\n",
1612 (gen9_powergate_status &
1613 GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down");
1614 seq_printf(m, "Media Power Well: %s\n",
1615 (gen9_powergate_status &
1616 GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down");
1617 }
Ben Widawskycce66a22012-03-27 18:59:38 -07001618
1619 /* Not exactly sure what this is */
Mika Kuoppala13628772017-03-15 17:43:02 +02001620 print_rc6_res(m, "RC6 \"Locked to RPn\" residency since boot:",
1621 GEN6_GT_GFX_RC6_LOCKED);
1622 print_rc6_res(m, "RC6 residency since boot:", GEN6_GT_GFX_RC6);
1623 print_rc6_res(m, "RC6+ residency since boot:", GEN6_GT_GFX_RC6p);
1624 print_rc6_res(m, "RC6++ residency since boot:", GEN6_GT_GFX_RC6pp);
Ben Widawskycce66a22012-03-27 18:59:38 -07001625
Ben Widawskyecd8fae2012-09-26 10:34:02 -07001626 seq_printf(m, "RC6 voltage: %dmV\n",
1627 GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff)));
1628 seq_printf(m, "RC6+ voltage: %dmV\n",
1629 GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff)));
1630 seq_printf(m, "RC6++ voltage: %dmV\n",
1631 GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff)));
Akash Goelf2dd7572016-06-27 20:10:01 +05301632 return i915_forcewake_domains(m, NULL);
Ben Widawsky4d855292011-12-12 19:34:16 -08001633}
1634
1635static int i915_drpc_info(struct seq_file *m, void *unused)
1636{
David Weinehall36cdd012016-08-22 13:59:31 +03001637 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001638 int err;
1639
1640 intel_runtime_pm_get(dev_priv);
Ben Widawsky4d855292011-12-12 19:34:16 -08001641
David Weinehall36cdd012016-08-22 13:59:31 +03001642 if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001643 err = vlv_drpc_info(m);
David Weinehall36cdd012016-08-22 13:59:31 +03001644 else if (INTEL_GEN(dev_priv) >= 6)
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001645 err = gen6_drpc_info(m);
Ben Widawsky4d855292011-12-12 19:34:16 -08001646 else
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001647 err = ironlake_drpc_info(m);
1648
1649 intel_runtime_pm_put(dev_priv);
1650
1651 return err;
Ben Widawsky4d855292011-12-12 19:34:16 -08001652}
1653
Daniel Vetter9a851782015-06-18 10:30:22 +02001654static int i915_frontbuffer_tracking(struct seq_file *m, void *unused)
1655{
David Weinehall36cdd012016-08-22 13:59:31 +03001656 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Daniel Vetter9a851782015-06-18 10:30:22 +02001657
1658 seq_printf(m, "FB tracking busy bits: 0x%08x\n",
1659 dev_priv->fb_tracking.busy_bits);
1660
1661 seq_printf(m, "FB tracking flip bits: 0x%08x\n",
1662 dev_priv->fb_tracking.flip_bits);
1663
1664 return 0;
1665}
1666
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001667static int i915_fbc_status(struct seq_file *m, void *unused)
1668{
David Weinehall36cdd012016-08-22 13:59:31 +03001669 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001670
David Weinehall36cdd012016-08-22 13:59:31 +03001671 if (!HAS_FBC(dev_priv)) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001672 seq_puts(m, "FBC unsupported on this chipset\n");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001673 return 0;
1674 }
1675
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001676 intel_runtime_pm_get(dev_priv);
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001677 mutex_lock(&dev_priv->fbc.lock);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001678
Paulo Zanoni0e631ad2015-10-14 17:45:36 -03001679 if (intel_fbc_is_active(dev_priv))
Damien Lespiau267f0c92013-06-24 22:59:48 +01001680 seq_puts(m, "FBC enabled\n");
Paulo Zanoni2e8144a2015-06-12 14:36:20 -03001681 else
1682 seq_printf(m, "FBC disabled: %s\n",
Paulo Zanonibf6189c2015-10-27 14:50:03 -02001683 dev_priv->fbc.no_fbc_reason);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001684
Ville Syrjälä3fd5d1e2017-06-06 15:43:18 +03001685 if (intel_fbc_is_active(dev_priv)) {
1686 u32 mask;
1687
1688 if (INTEL_GEN(dev_priv) >= 8)
1689 mask = I915_READ(IVB_FBC_STATUS2) & BDW_FBC_COMP_SEG_MASK;
1690 else if (INTEL_GEN(dev_priv) >= 7)
1691 mask = I915_READ(IVB_FBC_STATUS2) & IVB_FBC_COMP_SEG_MASK;
1692 else if (INTEL_GEN(dev_priv) >= 5)
1693 mask = I915_READ(ILK_DPFC_STATUS) & ILK_DPFC_COMP_SEG_MASK;
1694 else if (IS_G4X(dev_priv))
1695 mask = I915_READ(DPFC_STATUS) & DPFC_COMP_SEG_MASK;
1696 else
1697 mask = I915_READ(FBC_STATUS) & (FBC_STAT_COMPRESSING |
1698 FBC_STAT_COMPRESSED);
1699
1700 seq_printf(m, "Compressing: %s\n", yesno(mask));
Paulo Zanoni0fc6a9d2016-10-21 13:55:46 -02001701 }
Paulo Zanoni31b9df12015-06-12 14:36:18 -03001702
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001703 mutex_unlock(&dev_priv->fbc.lock);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001704 intel_runtime_pm_put(dev_priv);
1705
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001706 return 0;
1707}
1708
Ville Syrjälä4127dc42017-06-06 15:44:12 +03001709static int i915_fbc_false_color_get(void *data, u64 *val)
Rodrigo Vivida46f932014-08-01 02:04:45 -07001710{
David Weinehall36cdd012016-08-22 13:59:31 +03001711 struct drm_i915_private *dev_priv = data;
Rodrigo Vivida46f932014-08-01 02:04:45 -07001712
David Weinehall36cdd012016-08-22 13:59:31 +03001713 if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv))
Rodrigo Vivida46f932014-08-01 02:04:45 -07001714 return -ENODEV;
1715
Rodrigo Vivida46f932014-08-01 02:04:45 -07001716 *val = dev_priv->fbc.false_color;
Rodrigo Vivida46f932014-08-01 02:04:45 -07001717
1718 return 0;
1719}
1720
Ville Syrjälä4127dc42017-06-06 15:44:12 +03001721static int i915_fbc_false_color_set(void *data, u64 val)
Rodrigo Vivida46f932014-08-01 02:04:45 -07001722{
David Weinehall36cdd012016-08-22 13:59:31 +03001723 struct drm_i915_private *dev_priv = data;
Rodrigo Vivida46f932014-08-01 02:04:45 -07001724 u32 reg;
1725
David Weinehall36cdd012016-08-22 13:59:31 +03001726 if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv))
Rodrigo Vivida46f932014-08-01 02:04:45 -07001727 return -ENODEV;
1728
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001729 mutex_lock(&dev_priv->fbc.lock);
Rodrigo Vivida46f932014-08-01 02:04:45 -07001730
1731 reg = I915_READ(ILK_DPFC_CONTROL);
1732 dev_priv->fbc.false_color = val;
1733
1734 I915_WRITE(ILK_DPFC_CONTROL, val ?
1735 (reg | FBC_CTL_FALSE_COLOR) :
1736 (reg & ~FBC_CTL_FALSE_COLOR));
1737
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001738 mutex_unlock(&dev_priv->fbc.lock);
Rodrigo Vivida46f932014-08-01 02:04:45 -07001739 return 0;
1740}
1741
Ville Syrjälä4127dc42017-06-06 15:44:12 +03001742DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_false_color_fops,
1743 i915_fbc_false_color_get, i915_fbc_false_color_set,
Rodrigo Vivida46f932014-08-01 02:04:45 -07001744 "%llu\n");
1745
Paulo Zanoni92d44622013-05-31 16:33:24 -03001746static int i915_ips_status(struct seq_file *m, void *unused)
1747{
David Weinehall36cdd012016-08-22 13:59:31 +03001748 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Paulo Zanoni92d44622013-05-31 16:33:24 -03001749
David Weinehall36cdd012016-08-22 13:59:31 +03001750 if (!HAS_IPS(dev_priv)) {
Paulo Zanoni92d44622013-05-31 16:33:24 -03001751 seq_puts(m, "not supported\n");
1752 return 0;
1753 }
1754
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001755 intel_runtime_pm_get(dev_priv);
1756
Rodrigo Vivi0eaa53f2014-06-30 04:45:01 -07001757 seq_printf(m, "Enabled by kernel parameter: %s\n",
Michal Wajdeczko4f044a82017-09-19 19:38:44 +00001758 yesno(i915_modparams.enable_ips));
Rodrigo Vivi0eaa53f2014-06-30 04:45:01 -07001759
David Weinehall36cdd012016-08-22 13:59:31 +03001760 if (INTEL_GEN(dev_priv) >= 8) {
Rodrigo Vivi0eaa53f2014-06-30 04:45:01 -07001761 seq_puts(m, "Currently: unknown\n");
1762 } else {
1763 if (I915_READ(IPS_CTL) & IPS_ENABLE)
1764 seq_puts(m, "Currently: enabled\n");
1765 else
1766 seq_puts(m, "Currently: disabled\n");
1767 }
Paulo Zanoni92d44622013-05-31 16:33:24 -03001768
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001769 intel_runtime_pm_put(dev_priv);
1770
Paulo Zanoni92d44622013-05-31 16:33:24 -03001771 return 0;
1772}
1773
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001774static int i915_sr_status(struct seq_file *m, void *unused)
1775{
David Weinehall36cdd012016-08-22 13:59:31 +03001776 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001777 bool sr_enabled = false;
1778
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001779 intel_runtime_pm_get(dev_priv);
Chris Wilson9c870d02016-10-24 13:42:15 +01001780 intel_display_power_get(dev_priv, POWER_DOMAIN_INIT);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001781
Chris Wilson7342a722017-03-09 14:20:49 +00001782 if (INTEL_GEN(dev_priv) >= 9)
1783 /* no global SR status; inspect per-plane WM */;
1784 else if (HAS_PCH_SPLIT(dev_priv))
Chris Wilson5ba2aaa2010-08-19 18:04:08 +01001785 sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN;
Jani Nikulac0f86832016-12-07 12:13:04 +02001786 else if (IS_I965GM(dev_priv) || IS_G4X(dev_priv) ||
David Weinehall36cdd012016-08-22 13:59:31 +03001787 IS_I945G(dev_priv) || IS_I945GM(dev_priv))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001788 sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
David Weinehall36cdd012016-08-22 13:59:31 +03001789 else if (IS_I915GM(dev_priv))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001790 sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN;
David Weinehall36cdd012016-08-22 13:59:31 +03001791 else if (IS_PINEVIEW(dev_priv))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001792 sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN;
David Weinehall36cdd012016-08-22 13:59:31 +03001793 else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
Ander Conselvan de Oliveira77b64552015-06-02 14:17:47 +03001794 sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN;
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001795
Chris Wilson9c870d02016-10-24 13:42:15 +01001796 intel_display_power_put(dev_priv, POWER_DOMAIN_INIT);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001797 intel_runtime_pm_put(dev_priv);
1798
Tvrtko Ursulin08c4d7f2016-11-17 12:30:14 +00001799 seq_printf(m, "self-refresh: %s\n", enableddisabled(sr_enabled));
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001800
1801 return 0;
1802}
1803
Jesse Barnes7648fa92010-05-20 14:28:11 -07001804static int i915_emon_status(struct seq_file *m, void *unused)
1805{
David Weinehall36cdd012016-08-22 13:59:31 +03001806 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1807 struct drm_device *dev = &dev_priv->drm;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001808 unsigned long temp, chipset, gfx;
Chris Wilsonde227ef2010-07-03 07:58:38 +01001809 int ret;
1810
David Weinehall36cdd012016-08-22 13:59:31 +03001811 if (!IS_GEN5(dev_priv))
Chris Wilson582be6b2012-04-30 19:35:02 +01001812 return -ENODEV;
1813
Chris Wilsonde227ef2010-07-03 07:58:38 +01001814 ret = mutex_lock_interruptible(&dev->struct_mutex);
1815 if (ret)
1816 return ret;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001817
1818 temp = i915_mch_val(dev_priv);
1819 chipset = i915_chipset_val(dev_priv);
1820 gfx = i915_gfx_val(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +01001821 mutex_unlock(&dev->struct_mutex);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001822
1823 seq_printf(m, "GMCH temp: %ld\n", temp);
1824 seq_printf(m, "Chipset power: %ld\n", chipset);
1825 seq_printf(m, "GFX power: %ld\n", gfx);
1826 seq_printf(m, "Total power: %ld\n", chipset + gfx);
1827
1828 return 0;
1829}
1830
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001831static int i915_ring_freq_table(struct seq_file *m, void *unused)
1832{
David Weinehall36cdd012016-08-22 13:59:31 +03001833 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001834 int ret = 0;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001835 int gpu_freq, ia_freq;
Akash Goelf936ec32015-06-29 14:50:22 +05301836 unsigned int max_gpu_freq, min_gpu_freq;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001837
Carlos Santa26310342016-08-17 12:30:41 -07001838 if (!HAS_LLC(dev_priv)) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001839 seq_puts(m, "unsupported on this chipset\n");
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001840 return 0;
1841 }
1842
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001843 intel_runtime_pm_get(dev_priv);
1844
Jesse Barnes4fc688c2012-11-02 11:14:01 -07001845 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001846 if (ret)
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001847 goto out;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001848
Rodrigo Vivi35ceabf2017-07-06 13:41:13 -07001849 if (IS_GEN9_BC(dev_priv) || IS_CANNONLAKE(dev_priv)) {
Akash Goelf936ec32015-06-29 14:50:22 +05301850 /* Convert GT frequency to 50 HZ units */
1851 min_gpu_freq =
1852 dev_priv->rps.min_freq_softlimit / GEN9_FREQ_SCALER;
1853 max_gpu_freq =
1854 dev_priv->rps.max_freq_softlimit / GEN9_FREQ_SCALER;
1855 } else {
1856 min_gpu_freq = dev_priv->rps.min_freq_softlimit;
1857 max_gpu_freq = dev_priv->rps.max_freq_softlimit;
1858 }
1859
Damien Lespiau267f0c92013-06-24 22:59:48 +01001860 seq_puts(m, "GPU freq (MHz)\tEffective CPU freq (MHz)\tEffective Ring freq (MHz)\n");
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001861
Akash Goelf936ec32015-06-29 14:50:22 +05301862 for (gpu_freq = min_gpu_freq; gpu_freq <= max_gpu_freq; gpu_freq++) {
Ben Widawsky42c05262012-09-26 10:34:00 -07001863 ia_freq = gpu_freq;
1864 sandybridge_pcode_read(dev_priv,
1865 GEN6_PCODE_READ_MIN_FREQ_TABLE,
1866 &ia_freq);
Chris Wilson3ebecd02013-04-12 19:10:13 +01001867 seq_printf(m, "%d\t\t%d\t\t\t\t%d\n",
Akash Goelf936ec32015-06-29 14:50:22 +05301868 intel_gpu_freq(dev_priv, (gpu_freq *
Rodrigo Vivi35ceabf2017-07-06 13:41:13 -07001869 (IS_GEN9_BC(dev_priv) ||
1870 IS_CANNONLAKE(dev_priv) ?
Rodrigo Vivib976dc52017-01-23 10:32:37 -08001871 GEN9_FREQ_SCALER : 1))),
Chris Wilson3ebecd02013-04-12 19:10:13 +01001872 ((ia_freq >> 0) & 0xff) * 100,
1873 ((ia_freq >> 8) & 0xff) * 100);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001874 }
1875
Jesse Barnes4fc688c2012-11-02 11:14:01 -07001876 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001877
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001878out:
1879 intel_runtime_pm_put(dev_priv);
1880 return ret;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001881}
1882
Chris Wilson44834a62010-08-19 16:09:23 +01001883static int i915_opregion(struct seq_file *m, void *unused)
1884{
David Weinehall36cdd012016-08-22 13:59:31 +03001885 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1886 struct drm_device *dev = &dev_priv->drm;
Chris Wilson44834a62010-08-19 16:09:23 +01001887 struct intel_opregion *opregion = &dev_priv->opregion;
1888 int ret;
1889
1890 ret = mutex_lock_interruptible(&dev->struct_mutex);
1891 if (ret)
Daniel Vetter0d38f002012-04-21 22:49:10 +02001892 goto out;
Chris Wilson44834a62010-08-19 16:09:23 +01001893
Jani Nikula2455a8e2015-12-14 12:50:53 +02001894 if (opregion->header)
1895 seq_write(m, opregion->header, OPREGION_SIZE);
Chris Wilson44834a62010-08-19 16:09:23 +01001896
1897 mutex_unlock(&dev->struct_mutex);
1898
Daniel Vetter0d38f002012-04-21 22:49:10 +02001899out:
Chris Wilson44834a62010-08-19 16:09:23 +01001900 return 0;
1901}
1902
Jani Nikulaada8f952015-12-15 13:17:12 +02001903static int i915_vbt(struct seq_file *m, void *unused)
1904{
David Weinehall36cdd012016-08-22 13:59:31 +03001905 struct intel_opregion *opregion = &node_to_i915(m->private)->opregion;
Jani Nikulaada8f952015-12-15 13:17:12 +02001906
1907 if (opregion->vbt)
1908 seq_write(m, opregion->vbt, opregion->vbt_size);
1909
1910 return 0;
1911}
1912
Chris Wilson37811fc2010-08-25 22:45:57 +01001913static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
1914{
David Weinehall36cdd012016-08-22 13:59:31 +03001915 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1916 struct drm_device *dev = &dev_priv->drm;
Namrta Salonieb13b8402015-11-27 13:43:11 +05301917 struct intel_framebuffer *fbdev_fb = NULL;
Daniel Vetter3a58ee12015-07-10 19:02:51 +02001918 struct drm_framebuffer *drm_fb;
Chris Wilson188c1ab2016-04-03 14:14:20 +01001919 int ret;
1920
1921 ret = mutex_lock_interruptible(&dev->struct_mutex);
1922 if (ret)
1923 return ret;
Chris Wilson37811fc2010-08-25 22:45:57 +01001924
Daniel Vetter06957262015-08-10 13:34:08 +02001925#ifdef CONFIG_DRM_FBDEV_EMULATION
Daniel Vetter346fb4e2017-07-06 15:00:20 +02001926 if (dev_priv->fbdev && dev_priv->fbdev->helper.fb) {
David Weinehall36cdd012016-08-22 13:59:31 +03001927 fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb);
Chris Wilson37811fc2010-08-25 22:45:57 +01001928
Chris Wilson25bcce92016-07-02 15:36:00 +01001929 seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ",
1930 fbdev_fb->base.width,
1931 fbdev_fb->base.height,
Ville Syrjäläb00c6002016-12-14 23:31:35 +02001932 fbdev_fb->base.format->depth,
Ville Syrjälä272725c2016-12-14 23:32:20 +02001933 fbdev_fb->base.format->cpp[0] * 8,
Ville Syrjäläbae781b2016-11-16 13:33:16 +02001934 fbdev_fb->base.modifier,
Chris Wilson25bcce92016-07-02 15:36:00 +01001935 drm_framebuffer_read_refcount(&fbdev_fb->base));
1936 describe_obj(m, fbdev_fb->obj);
1937 seq_putc(m, '\n');
1938 }
Daniel Vetter4520f532013-10-09 09:18:51 +02001939#endif
Chris Wilson37811fc2010-08-25 22:45:57 +01001940
Daniel Vetter4b096ac2012-12-10 21:19:18 +01001941 mutex_lock(&dev->mode_config.fb_lock);
Daniel Vetter3a58ee12015-07-10 19:02:51 +02001942 drm_for_each_fb(drm_fb, dev) {
Namrta Salonieb13b8402015-11-27 13:43:11 +05301943 struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb);
1944 if (fb == fbdev_fb)
Chris Wilson37811fc2010-08-25 22:45:57 +01001945 continue;
1946
Tvrtko Ursulinc1ca506d2015-02-10 17:16:07 +00001947 seq_printf(m, "user size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ",
Chris Wilson37811fc2010-08-25 22:45:57 +01001948 fb->base.width,
1949 fb->base.height,
Ville Syrjäläb00c6002016-12-14 23:31:35 +02001950 fb->base.format->depth,
Ville Syrjälä272725c2016-12-14 23:32:20 +02001951 fb->base.format->cpp[0] * 8,
Ville Syrjäläbae781b2016-11-16 13:33:16 +02001952 fb->base.modifier,
Dave Airlie747a5982016-04-15 15:10:35 +10001953 drm_framebuffer_read_refcount(&fb->base));
Chris Wilson05394f32010-11-08 19:18:58 +00001954 describe_obj(m, fb->obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +01001955 seq_putc(m, '\n');
Chris Wilson37811fc2010-08-25 22:45:57 +01001956 }
Daniel Vetter4b096ac2012-12-10 21:19:18 +01001957 mutex_unlock(&dev->mode_config.fb_lock);
Chris Wilson188c1ab2016-04-03 14:14:20 +01001958 mutex_unlock(&dev->struct_mutex);
Chris Wilson37811fc2010-08-25 22:45:57 +01001959
1960 return 0;
1961}
1962
Chris Wilson7e37f882016-08-02 22:50:21 +01001963static void describe_ctx_ring(struct seq_file *m, struct intel_ring *ring)
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001964{
Chris Wilsonfe085f12017-03-21 10:25:52 +00001965 seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u)",
1966 ring->space, ring->head, ring->tail);
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001967}
1968
Ben Widawskye76d3632011-03-19 18:14:29 -07001969static int i915_context_status(struct seq_file *m, void *unused)
1970{
David Weinehall36cdd012016-08-22 13:59:31 +03001971 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1972 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001973 struct intel_engine_cs *engine;
Chris Wilsone2efd132016-05-24 14:53:34 +01001974 struct i915_gem_context *ctx;
Akash Goel3b3f1652016-10-13 22:44:48 +05301975 enum intel_engine_id id;
Dave Gordonc3232b12016-03-23 18:19:53 +00001976 int ret;
Ben Widawskye76d3632011-03-19 18:14:29 -07001977
Daniel Vetterf3d28872014-05-29 23:23:08 +02001978 ret = mutex_lock_interruptible(&dev->struct_mutex);
Ben Widawskye76d3632011-03-19 18:14:29 -07001979 if (ret)
1980 return ret;
1981
Chris Wilson829a0af2017-06-20 12:05:45 +01001982 list_for_each_entry(ctx, &dev_priv->contexts.list, link) {
Chris Wilson5d1808e2016-04-28 09:56:51 +01001983 seq_printf(m, "HW context %u ", ctx->hw_id);
Chris Wilsonc84455b2016-08-15 10:49:08 +01001984 if (ctx->pid) {
Chris Wilsond28b99a2016-05-24 14:53:39 +01001985 struct task_struct *task;
1986
Chris Wilsonc84455b2016-08-15 10:49:08 +01001987 task = get_pid_task(ctx->pid, PIDTYPE_PID);
Chris Wilsond28b99a2016-05-24 14:53:39 +01001988 if (task) {
1989 seq_printf(m, "(%s [%d]) ",
1990 task->comm, task->pid);
1991 put_task_struct(task);
1992 }
Chris Wilsonc84455b2016-08-15 10:49:08 +01001993 } else if (IS_ERR(ctx->file_priv)) {
1994 seq_puts(m, "(deleted) ");
Chris Wilsond28b99a2016-05-24 14:53:39 +01001995 } else {
1996 seq_puts(m, "(kernel) ");
1997 }
1998
Chris Wilsonbca44d82016-05-24 14:53:41 +01001999 seq_putc(m, ctx->remap_slice ? 'R' : 'r');
2000 seq_putc(m, '\n');
Ben Widawskya33afea2013-09-17 21:12:45 -07002001
Akash Goel3b3f1652016-10-13 22:44:48 +05302002 for_each_engine(engine, dev_priv, id) {
Chris Wilsonbca44d82016-05-24 14:53:41 +01002003 struct intel_context *ce = &ctx->engine[engine->id];
2004
2005 seq_printf(m, "%s: ", engine->name);
2006 seq_putc(m, ce->initialised ? 'I' : 'i');
2007 if (ce->state)
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002008 describe_obj(m, ce->state->obj);
Chris Wilsondca33ec2016-08-02 22:50:20 +01002009 if (ce->ring)
Chris Wilson7e37f882016-08-02 22:50:21 +01002010 describe_ctx_ring(m, ce->ring);
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01002011 seq_putc(m, '\n');
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01002012 }
2013
Ben Widawskya33afea2013-09-17 21:12:45 -07002014 seq_putc(m, '\n');
Ben Widawskya168c292013-02-14 15:05:12 -08002015 }
2016
Daniel Vetterf3d28872014-05-29 23:23:08 +02002017 mutex_unlock(&dev->struct_mutex);
Ben Widawskye76d3632011-03-19 18:14:29 -07002018
2019 return 0;
2020}
2021
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002022static void i915_dump_lrc_obj(struct seq_file *m,
Chris Wilsone2efd132016-05-24 14:53:34 +01002023 struct i915_gem_context *ctx,
Tvrtko Ursulin0bc40be2016-03-16 11:00:37 +00002024 struct intel_engine_cs *engine)
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002025{
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002026 struct i915_vma *vma = ctx->engine[engine->id].state;
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002027 struct page *page;
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002028 int j;
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002029
Chris Wilson7069b142016-04-28 09:56:52 +01002030 seq_printf(m, "CONTEXT: %s %u\n", engine->name, ctx->hw_id);
2031
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002032 if (!vma) {
2033 seq_puts(m, "\tFake context\n");
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002034 return;
2035 }
2036
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002037 if (vma->flags & I915_VMA_GLOBAL_BIND)
2038 seq_printf(m, "\tBound in GGTT at 0x%08x\n",
Chris Wilsonbde13eb2016-08-15 10:49:07 +01002039 i915_ggtt_offset(vma));
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002040
Chris Wilsona4f5ea62016-10-28 13:58:35 +01002041 if (i915_gem_object_pin_pages(vma->obj)) {
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002042 seq_puts(m, "\tFailed to get pages for context object\n\n");
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002043 return;
2044 }
2045
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002046 page = i915_gem_object_get_page(vma->obj, LRC_STATE_PN);
2047 if (page) {
2048 u32 *reg_state = kmap_atomic(page);
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002049
2050 for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) {
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002051 seq_printf(m,
2052 "\t[0x%04x] 0x%08x 0x%08x 0x%08x 0x%08x\n",
2053 j * 4,
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002054 reg_state[j], reg_state[j + 1],
2055 reg_state[j + 2], reg_state[j + 3]);
2056 }
2057 kunmap_atomic(reg_state);
2058 }
2059
Chris Wilsona4f5ea62016-10-28 13:58:35 +01002060 i915_gem_object_unpin_pages(vma->obj);
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002061 seq_putc(m, '\n');
2062}
2063
Ben Widawskyc0ab1ae92014-08-07 13:24:26 +01002064static int i915_dump_lrc(struct seq_file *m, void *unused)
2065{
David Weinehall36cdd012016-08-22 13:59:31 +03002066 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2067 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002068 struct intel_engine_cs *engine;
Chris Wilsone2efd132016-05-24 14:53:34 +01002069 struct i915_gem_context *ctx;
Akash Goel3b3f1652016-10-13 22:44:48 +05302070 enum intel_engine_id id;
Dave Gordonb4ac5af2016-03-24 11:20:38 +00002071 int ret;
Ben Widawskyc0ab1ae92014-08-07 13:24:26 +01002072
Michal Wajdeczko4f044a82017-09-19 19:38:44 +00002073 if (!i915_modparams.enable_execlists) {
Ben Widawskyc0ab1ae92014-08-07 13:24:26 +01002074 seq_printf(m, "Logical Ring Contexts are disabled\n");
2075 return 0;
2076 }
2077
2078 ret = mutex_lock_interruptible(&dev->struct_mutex);
2079 if (ret)
2080 return ret;
2081
Chris Wilson829a0af2017-06-20 12:05:45 +01002082 list_for_each_entry(ctx, &dev_priv->contexts.list, link)
Akash Goel3b3f1652016-10-13 22:44:48 +05302083 for_each_engine(engine, dev_priv, id)
Chris Wilson24f1d3c2016-04-28 09:56:53 +01002084 i915_dump_lrc_obj(m, ctx, engine);
Ben Widawskyc0ab1ae92014-08-07 13:24:26 +01002085
2086 mutex_unlock(&dev->struct_mutex);
2087
2088 return 0;
2089}
2090
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002091static const char *swizzle_string(unsigned swizzle)
2092{
Damien Lespiauaee56cf2013-06-24 22:59:49 +01002093 switch (swizzle) {
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002094 case I915_BIT_6_SWIZZLE_NONE:
2095 return "none";
2096 case I915_BIT_6_SWIZZLE_9:
2097 return "bit9";
2098 case I915_BIT_6_SWIZZLE_9_10:
2099 return "bit9/bit10";
2100 case I915_BIT_6_SWIZZLE_9_11:
2101 return "bit9/bit11";
2102 case I915_BIT_6_SWIZZLE_9_10_11:
2103 return "bit9/bit10/bit11";
2104 case I915_BIT_6_SWIZZLE_9_17:
2105 return "bit9/bit17";
2106 case I915_BIT_6_SWIZZLE_9_10_17:
2107 return "bit9/bit10/bit17";
2108 case I915_BIT_6_SWIZZLE_UNKNOWN:
Masanari Iida8a168ca2012-12-29 02:00:09 +09002109 return "unknown";
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002110 }
2111
2112 return "bug";
2113}
2114
2115static int i915_swizzle_info(struct seq_file *m, void *data)
2116{
David Weinehall36cdd012016-08-22 13:59:31 +03002117 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002118
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002119 intel_runtime_pm_get(dev_priv);
Daniel Vetter22bcfc62012-08-09 15:07:02 +02002120
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002121 seq_printf(m, "bit6 swizzle for X-tiling = %s\n",
2122 swizzle_string(dev_priv->mm.bit_6_swizzle_x));
2123 seq_printf(m, "bit6 swizzle for Y-tiling = %s\n",
2124 swizzle_string(dev_priv->mm.bit_6_swizzle_y));
2125
David Weinehall36cdd012016-08-22 13:59:31 +03002126 if (IS_GEN3(dev_priv) || IS_GEN4(dev_priv)) {
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002127 seq_printf(m, "DDC = 0x%08x\n",
2128 I915_READ(DCC));
Daniel Vetter656bfa32014-11-20 09:26:30 +01002129 seq_printf(m, "DDC2 = 0x%08x\n",
2130 I915_READ(DCC2));
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002131 seq_printf(m, "C0DRB3 = 0x%04x\n",
2132 I915_READ16(C0DRB3));
2133 seq_printf(m, "C1DRB3 = 0x%04x\n",
2134 I915_READ16(C1DRB3));
David Weinehall36cdd012016-08-22 13:59:31 +03002135 } else if (INTEL_GEN(dev_priv) >= 6) {
Daniel Vetter3fa7d232012-01-31 16:47:56 +01002136 seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n",
2137 I915_READ(MAD_DIMM_C0));
2138 seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n",
2139 I915_READ(MAD_DIMM_C1));
2140 seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n",
2141 I915_READ(MAD_DIMM_C2));
2142 seq_printf(m, "TILECTL = 0x%08x\n",
2143 I915_READ(TILECTL));
David Weinehall36cdd012016-08-22 13:59:31 +03002144 if (INTEL_GEN(dev_priv) >= 8)
Ben Widawsky9d3203e2013-11-02 21:07:14 -07002145 seq_printf(m, "GAMTARBMODE = 0x%08x\n",
2146 I915_READ(GAMTARBMODE));
2147 else
2148 seq_printf(m, "ARB_MODE = 0x%08x\n",
2149 I915_READ(ARB_MODE));
Daniel Vetter3fa7d232012-01-31 16:47:56 +01002150 seq_printf(m, "DISP_ARB_CTL = 0x%08x\n",
2151 I915_READ(DISP_ARB_CTL));
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002152 }
Daniel Vetter656bfa32014-11-20 09:26:30 +01002153
2154 if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES)
2155 seq_puts(m, "L-shaped memory detected\n");
2156
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002157 intel_runtime_pm_put(dev_priv);
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002158
2159 return 0;
2160}
2161
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002162static int per_file_ctx(int id, void *ptr, void *data)
2163{
Chris Wilsone2efd132016-05-24 14:53:34 +01002164 struct i915_gem_context *ctx = ptr;
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002165 struct seq_file *m = data;
Daniel Vetterae6c4802014-08-06 15:04:53 +02002166 struct i915_hw_ppgtt *ppgtt = ctx->ppgtt;
2167
2168 if (!ppgtt) {
2169 seq_printf(m, " no ppgtt for context %d\n",
2170 ctx->user_handle);
2171 return 0;
2172 }
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002173
Oscar Mateof83d6512014-05-22 14:13:38 +01002174 if (i915_gem_context_is_default(ctx))
2175 seq_puts(m, " default context:\n");
2176 else
Oscar Mateo821d66d2014-07-03 16:28:00 +01002177 seq_printf(m, " context %d:\n", ctx->user_handle);
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002178 ppgtt->debug_dump(ppgtt, m);
2179
2180 return 0;
2181}
2182
David Weinehall36cdd012016-08-22 13:59:31 +03002183static void gen8_ppgtt_info(struct seq_file *m,
2184 struct drm_i915_private *dev_priv)
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002185{
Ben Widawsky77df6772013-11-02 21:07:30 -07002186 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
Akash Goel3b3f1652016-10-13 22:44:48 +05302187 struct intel_engine_cs *engine;
2188 enum intel_engine_id id;
Dave Gordonb4ac5af2016-03-24 11:20:38 +00002189 int i;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002190
Ben Widawsky77df6772013-11-02 21:07:30 -07002191 if (!ppgtt)
2192 return;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002193
Akash Goel3b3f1652016-10-13 22:44:48 +05302194 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002195 seq_printf(m, "%s\n", engine->name);
Ben Widawsky77df6772013-11-02 21:07:30 -07002196 for (i = 0; i < 4; i++) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002197 u64 pdp = I915_READ(GEN8_RING_PDP_UDW(engine, i));
Ben Widawsky77df6772013-11-02 21:07:30 -07002198 pdp <<= 32;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002199 pdp |= I915_READ(GEN8_RING_PDP_LDW(engine, i));
Ville Syrjäläa2a5b152014-03-31 18:17:16 +03002200 seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp);
Ben Widawsky77df6772013-11-02 21:07:30 -07002201 }
2202 }
2203}
2204
David Weinehall36cdd012016-08-22 13:59:31 +03002205static void gen6_ppgtt_info(struct seq_file *m,
2206 struct drm_i915_private *dev_priv)
Ben Widawsky77df6772013-11-02 21:07:30 -07002207{
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002208 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +05302209 enum intel_engine_id id;
Ben Widawsky77df6772013-11-02 21:07:30 -07002210
Tvrtko Ursulin7e22dbb2016-05-10 10:57:06 +01002211 if (IS_GEN6(dev_priv))
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002212 seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE));
2213
Akash Goel3b3f1652016-10-13 22:44:48 +05302214 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002215 seq_printf(m, "%s\n", engine->name);
Tvrtko Ursulin7e22dbb2016-05-10 10:57:06 +01002216 if (IS_GEN7(dev_priv))
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002217 seq_printf(m, "GFX_MODE: 0x%08x\n",
2218 I915_READ(RING_MODE_GEN7(engine)));
2219 seq_printf(m, "PP_DIR_BASE: 0x%08x\n",
2220 I915_READ(RING_PP_DIR_BASE(engine)));
2221 seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n",
2222 I915_READ(RING_PP_DIR_BASE_READ(engine)));
2223 seq_printf(m, "PP_DIR_DCLV: 0x%08x\n",
2224 I915_READ(RING_PP_DIR_DCLV(engine)));
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002225 }
2226 if (dev_priv->mm.aliasing_ppgtt) {
2227 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
2228
Damien Lespiau267f0c92013-06-24 22:59:48 +01002229 seq_puts(m, "aliasing PPGTT:\n");
Mika Kuoppala44159dd2015-06-25 18:35:07 +03002230 seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd.base.ggtt_offset);
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002231
Ben Widawsky87d60b62013-12-06 14:11:29 -08002232 ppgtt->debug_dump(ppgtt, m);
Daniel Vetterae6c4802014-08-06 15:04:53 +02002233 }
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002234
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002235 seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK));
Ben Widawsky77df6772013-11-02 21:07:30 -07002236}
2237
2238static int i915_ppgtt_info(struct seq_file *m, void *data)
2239{
David Weinehall36cdd012016-08-22 13:59:31 +03002240 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2241 struct drm_device *dev = &dev_priv->drm;
Michel Thierryea91e402015-07-29 17:23:57 +01002242 struct drm_file *file;
Chris Wilson637ee292016-08-22 14:28:20 +01002243 int ret;
Ben Widawsky77df6772013-11-02 21:07:30 -07002244
Chris Wilson637ee292016-08-22 14:28:20 +01002245 mutex_lock(&dev->filelist_mutex);
2246 ret = mutex_lock_interruptible(&dev->struct_mutex);
Ben Widawsky77df6772013-11-02 21:07:30 -07002247 if (ret)
Chris Wilson637ee292016-08-22 14:28:20 +01002248 goto out_unlock;
2249
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002250 intel_runtime_pm_get(dev_priv);
Ben Widawsky77df6772013-11-02 21:07:30 -07002251
David Weinehall36cdd012016-08-22 13:59:31 +03002252 if (INTEL_GEN(dev_priv) >= 8)
2253 gen8_ppgtt_info(m, dev_priv);
2254 else if (INTEL_GEN(dev_priv) >= 6)
2255 gen6_ppgtt_info(m, dev_priv);
Ben Widawsky77df6772013-11-02 21:07:30 -07002256
Michel Thierryea91e402015-07-29 17:23:57 +01002257 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
2258 struct drm_i915_file_private *file_priv = file->driver_priv;
Geliang Tang7cb5dff2015-09-25 03:58:11 -07002259 struct task_struct *task;
Michel Thierryea91e402015-07-29 17:23:57 +01002260
Geliang Tang7cb5dff2015-09-25 03:58:11 -07002261 task = get_pid_task(file->pid, PIDTYPE_PID);
Dan Carpenter06812762015-10-02 18:14:22 +03002262 if (!task) {
2263 ret = -ESRCH;
Chris Wilson637ee292016-08-22 14:28:20 +01002264 goto out_rpm;
Dan Carpenter06812762015-10-02 18:14:22 +03002265 }
Geliang Tang7cb5dff2015-09-25 03:58:11 -07002266 seq_printf(m, "\nproc: %s\n", task->comm);
2267 put_task_struct(task);
Michel Thierryea91e402015-07-29 17:23:57 +01002268 idr_for_each(&file_priv->context_idr, per_file_ctx,
2269 (void *)(unsigned long)m);
2270 }
2271
Chris Wilson637ee292016-08-22 14:28:20 +01002272out_rpm:
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002273 intel_runtime_pm_put(dev_priv);
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002274 mutex_unlock(&dev->struct_mutex);
Chris Wilson637ee292016-08-22 14:28:20 +01002275out_unlock:
2276 mutex_unlock(&dev->filelist_mutex);
Dan Carpenter06812762015-10-02 18:14:22 +03002277 return ret;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002278}
2279
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002280static int count_irq_waiters(struct drm_i915_private *i915)
2281{
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002282 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +05302283 enum intel_engine_id id;
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002284 int count = 0;
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002285
Akash Goel3b3f1652016-10-13 22:44:48 +05302286 for_each_engine(engine, i915, id)
Chris Wilson688e6c72016-07-01 17:23:15 +01002287 count += intel_engine_has_waiter(engine);
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002288
2289 return count;
2290}
2291
Chris Wilson7466c292016-08-15 09:49:33 +01002292static const char *rps_power_to_str(unsigned int power)
2293{
2294 static const char * const strings[] = {
2295 [LOW_POWER] = "low power",
2296 [BETWEEN] = "mixed",
2297 [HIGH_POWER] = "high power",
2298 };
2299
2300 if (power >= ARRAY_SIZE(strings) || !strings[power])
2301 return "unknown";
2302
2303 return strings[power];
2304}
2305
Chris Wilson1854d5c2015-04-07 16:20:32 +01002306static int i915_rps_boost_info(struct seq_file *m, void *data)
2307{
David Weinehall36cdd012016-08-22 13:59:31 +03002308 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2309 struct drm_device *dev = &dev_priv->drm;
Chris Wilson1854d5c2015-04-07 16:20:32 +01002310 struct drm_file *file;
Chris Wilson1854d5c2015-04-07 16:20:32 +01002311
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002312 seq_printf(m, "RPS enabled? %d\n", dev_priv->rps.enabled);
Chris Wilson28176ef2016-10-28 13:58:56 +01002313 seq_printf(m, "GPU busy? %s [%d requests]\n",
2314 yesno(dev_priv->gt.awake), dev_priv->gt.active_requests);
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002315 seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv));
Chris Wilson7b92c1b2017-06-28 13:35:48 +01002316 seq_printf(m, "Boosts outstanding? %d\n",
2317 atomic_read(&dev_priv->rps.num_waiters));
Chris Wilson7466c292016-08-15 09:49:33 +01002318 seq_printf(m, "Frequency requested %d\n",
2319 intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq));
2320 seq_printf(m, " min hard:%d, soft:%d; max soft:%d, hard:%d\n",
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002321 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq),
2322 intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit),
2323 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit),
2324 intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
Chris Wilson7466c292016-08-15 09:49:33 +01002325 seq_printf(m, " idle:%d, efficient:%d, boost:%d\n",
2326 intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq),
2327 intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq),
2328 intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq));
Daniel Vetter1d2ac402016-04-26 19:29:41 +02002329
2330 mutex_lock(&dev->filelist_mutex);
Chris Wilson1854d5c2015-04-07 16:20:32 +01002331 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
2332 struct drm_i915_file_private *file_priv = file->driver_priv;
2333 struct task_struct *task;
2334
2335 rcu_read_lock();
2336 task = pid_task(file->pid, PIDTYPE_PID);
Chris Wilson7b92c1b2017-06-28 13:35:48 +01002337 seq_printf(m, "%s [%d]: %d boosts\n",
Chris Wilson1854d5c2015-04-07 16:20:32 +01002338 task ? task->comm : "<unknown>",
2339 task ? task->pid : -1,
Chris Wilson7b92c1b2017-06-28 13:35:48 +01002340 atomic_read(&file_priv->rps.boosts));
Chris Wilson1854d5c2015-04-07 16:20:32 +01002341 rcu_read_unlock();
2342 }
Chris Wilson7b92c1b2017-06-28 13:35:48 +01002343 seq_printf(m, "Kernel (anonymous) boosts: %d\n",
2344 atomic_read(&dev_priv->rps.boosts));
Daniel Vetter1d2ac402016-04-26 19:29:41 +02002345 mutex_unlock(&dev->filelist_mutex);
Chris Wilson1854d5c2015-04-07 16:20:32 +01002346
Chris Wilson7466c292016-08-15 09:49:33 +01002347 if (INTEL_GEN(dev_priv) >= 6 &&
2348 dev_priv->rps.enabled &&
Chris Wilson28176ef2016-10-28 13:58:56 +01002349 dev_priv->gt.active_requests) {
Chris Wilson7466c292016-08-15 09:49:33 +01002350 u32 rpup, rpupei;
2351 u32 rpdown, rpdownei;
2352
2353 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
2354 rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK;
2355 rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK;
2356 rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK;
2357 rpdownei = I915_READ_FW(GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK;
2358 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
2359
2360 seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n",
2361 rps_power_to_str(dev_priv->rps.power));
2362 seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n",
Chris Wilson23f4a282017-02-18 11:27:08 +00002363 rpup && rpupei ? 100 * rpup / rpupei : 0,
Chris Wilson7466c292016-08-15 09:49:33 +01002364 dev_priv->rps.up_threshold);
2365 seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n",
Chris Wilson23f4a282017-02-18 11:27:08 +00002366 rpdown && rpdownei ? 100 * rpdown / rpdownei : 0,
Chris Wilson7466c292016-08-15 09:49:33 +01002367 dev_priv->rps.down_threshold);
2368 } else {
2369 seq_puts(m, "\nRPS Autotuning inactive\n");
2370 }
2371
Chris Wilson8d3afd72015-05-21 21:01:47 +01002372 return 0;
Chris Wilson1854d5c2015-04-07 16:20:32 +01002373}
2374
Ben Widawsky63573eb2013-07-04 11:02:07 -07002375static int i915_llc(struct seq_file *m, void *data)
2376{
David Weinehall36cdd012016-08-22 13:59:31 +03002377 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Mika Kuoppala3accaf72016-04-13 17:26:43 +03002378 const bool edram = INTEL_GEN(dev_priv) > 8;
Ben Widawsky63573eb2013-07-04 11:02:07 -07002379
David Weinehall36cdd012016-08-22 13:59:31 +03002380 seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv)));
Mika Kuoppala3accaf72016-04-13 17:26:43 +03002381 seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC",
2382 intel_uncore_edram_size(dev_priv)/1024/1024);
Ben Widawsky63573eb2013-07-04 11:02:07 -07002383
2384 return 0;
2385}
2386
Anusha Srivatsa0509ead2017-01-18 08:05:56 -08002387static int i915_huc_load_status_info(struct seq_file *m, void *data)
2388{
2389 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2390 struct intel_uc_fw *huc_fw = &dev_priv->huc.fw;
2391
2392 if (!HAS_HUC_UCODE(dev_priv))
2393 return 0;
2394
2395 seq_puts(m, "HuC firmware status:\n");
2396 seq_printf(m, "\tpath: %s\n", huc_fw->path);
2397 seq_printf(m, "\tfetch: %s\n",
2398 intel_uc_fw_status_repr(huc_fw->fetch_status));
2399 seq_printf(m, "\tload: %s\n",
2400 intel_uc_fw_status_repr(huc_fw->load_status));
2401 seq_printf(m, "\tversion wanted: %d.%d\n",
2402 huc_fw->major_ver_wanted, huc_fw->minor_ver_wanted);
2403 seq_printf(m, "\tversion found: %d.%d\n",
2404 huc_fw->major_ver_found, huc_fw->minor_ver_found);
2405 seq_printf(m, "\theader: offset is %d; size = %d\n",
2406 huc_fw->header_offset, huc_fw->header_size);
2407 seq_printf(m, "\tuCode: offset is %d; size = %d\n",
2408 huc_fw->ucode_offset, huc_fw->ucode_size);
2409 seq_printf(m, "\tRSA: offset is %d; size = %d\n",
2410 huc_fw->rsa_offset, huc_fw->rsa_size);
2411
sagar.a.kamble@intel.com3582ad12017-02-03 13:58:33 +05302412 intel_runtime_pm_get(dev_priv);
Anusha Srivatsa0509ead2017-01-18 08:05:56 -08002413 seq_printf(m, "\nHuC status 0x%08x:\n", I915_READ(HUC_STATUS2));
sagar.a.kamble@intel.com3582ad12017-02-03 13:58:33 +05302414 intel_runtime_pm_put(dev_priv);
Anusha Srivatsa0509ead2017-01-18 08:05:56 -08002415
2416 return 0;
2417}
2418
Alex Daifdf5d352015-08-12 15:43:37 +01002419static int i915_guc_load_status_info(struct seq_file *m, void *data)
2420{
David Weinehall36cdd012016-08-22 13:59:31 +03002421 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Anusha Srivatsadb0a0912017-01-13 17:17:04 -08002422 struct intel_uc_fw *guc_fw = &dev_priv->guc.fw;
Alex Daifdf5d352015-08-12 15:43:37 +01002423 u32 tmp, i;
2424
Joonas Lahtinen2d1fe072016-04-07 11:08:05 +03002425 if (!HAS_GUC_UCODE(dev_priv))
Alex Daifdf5d352015-08-12 15:43:37 +01002426 return 0;
2427
2428 seq_printf(m, "GuC firmware status:\n");
2429 seq_printf(m, "\tpath: %s\n",
Anusha Srivatsadb0a0912017-01-13 17:17:04 -08002430 guc_fw->path);
Alex Daifdf5d352015-08-12 15:43:37 +01002431 seq_printf(m, "\tfetch: %s\n",
Anusha Srivatsadb0a0912017-01-13 17:17:04 -08002432 intel_uc_fw_status_repr(guc_fw->fetch_status));
Alex Daifdf5d352015-08-12 15:43:37 +01002433 seq_printf(m, "\tload: %s\n",
Anusha Srivatsadb0a0912017-01-13 17:17:04 -08002434 intel_uc_fw_status_repr(guc_fw->load_status));
Alex Daifdf5d352015-08-12 15:43:37 +01002435 seq_printf(m, "\tversion wanted: %d.%d\n",
Anusha Srivatsadb0a0912017-01-13 17:17:04 -08002436 guc_fw->major_ver_wanted, guc_fw->minor_ver_wanted);
Alex Daifdf5d352015-08-12 15:43:37 +01002437 seq_printf(m, "\tversion found: %d.%d\n",
Anusha Srivatsadb0a0912017-01-13 17:17:04 -08002438 guc_fw->major_ver_found, guc_fw->minor_ver_found);
Alex Daifeda33e2015-10-19 16:10:54 -07002439 seq_printf(m, "\theader: offset is %d; size = %d\n",
2440 guc_fw->header_offset, guc_fw->header_size);
2441 seq_printf(m, "\tuCode: offset is %d; size = %d\n",
2442 guc_fw->ucode_offset, guc_fw->ucode_size);
2443 seq_printf(m, "\tRSA: offset is %d; size = %d\n",
2444 guc_fw->rsa_offset, guc_fw->rsa_size);
Alex Daifdf5d352015-08-12 15:43:37 +01002445
sagar.a.kamble@intel.com3582ad12017-02-03 13:58:33 +05302446 intel_runtime_pm_get(dev_priv);
2447
Alex Daifdf5d352015-08-12 15:43:37 +01002448 tmp = I915_READ(GUC_STATUS);
2449
2450 seq_printf(m, "\nGuC status 0x%08x:\n", tmp);
2451 seq_printf(m, "\tBootrom status = 0x%x\n",
2452 (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT);
2453 seq_printf(m, "\tuKernel status = 0x%x\n",
2454 (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT);
2455 seq_printf(m, "\tMIA Core status = 0x%x\n",
2456 (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT);
2457 seq_puts(m, "\nScratch registers:\n");
2458 for (i = 0; i < 16; i++)
2459 seq_printf(m, "\t%2d: \t0x%x\n", i, I915_READ(SOFT_SCRATCH(i)));
2460
sagar.a.kamble@intel.com3582ad12017-02-03 13:58:33 +05302461 intel_runtime_pm_put(dev_priv);
2462
Alex Daifdf5d352015-08-12 15:43:37 +01002463 return 0;
2464}
2465
Akash Goel5aa1ee42016-10-12 21:54:36 +05302466static void i915_guc_log_info(struct seq_file *m,
2467 struct drm_i915_private *dev_priv)
2468{
2469 struct intel_guc *guc = &dev_priv->guc;
2470
2471 seq_puts(m, "\nGuC logging stats:\n");
2472
2473 seq_printf(m, "\tISR: flush count %10u, overflow count %10u\n",
2474 guc->log.flush_count[GUC_ISR_LOG_BUFFER],
2475 guc->log.total_overflow_count[GUC_ISR_LOG_BUFFER]);
2476
2477 seq_printf(m, "\tDPC: flush count %10u, overflow count %10u\n",
2478 guc->log.flush_count[GUC_DPC_LOG_BUFFER],
2479 guc->log.total_overflow_count[GUC_DPC_LOG_BUFFER]);
2480
2481 seq_printf(m, "\tCRASH: flush count %10u, overflow count %10u\n",
2482 guc->log.flush_count[GUC_CRASH_DUMP_LOG_BUFFER],
2483 guc->log.total_overflow_count[GUC_CRASH_DUMP_LOG_BUFFER]);
2484
2485 seq_printf(m, "\tTotal flush interrupt count: %u\n",
2486 guc->log.flush_interrupt_count);
2487
2488 seq_printf(m, "\tCapture miss count: %u\n",
2489 guc->log.capture_miss_count);
2490}
2491
Dave Gordon8b417c22015-08-12 15:43:44 +01002492static void i915_guc_client_info(struct seq_file *m,
2493 struct drm_i915_private *dev_priv,
2494 struct i915_guc_client *client)
2495{
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002496 struct intel_engine_cs *engine;
Dave Gordonc18468c2016-08-09 15:19:22 +01002497 enum intel_engine_id id;
Dave Gordon8b417c22015-08-12 15:43:44 +01002498 uint64_t tot = 0;
Dave Gordon8b417c22015-08-12 15:43:44 +01002499
Oscar Mateob09935a2017-03-22 10:39:53 -07002500 seq_printf(m, "\tPriority %d, GuC stage index: %u, PD offset 0x%x\n",
2501 client->priority, client->stage_id, client->proc_desc_offset);
Michał Winiarski59db36c2017-09-14 12:51:23 +02002502 seq_printf(m, "\tDoorbell id %d, offset: 0x%lx\n",
2503 client->doorbell_id, client->doorbell_offset);
Dave Gordon8b417c22015-08-12 15:43:44 +01002504
Akash Goel3b3f1652016-10-13 22:44:48 +05302505 for_each_engine(engine, dev_priv, id) {
Dave Gordonc18468c2016-08-09 15:19:22 +01002506 u64 submissions = client->submissions[id];
2507 tot += submissions;
Dave Gordon8b417c22015-08-12 15:43:44 +01002508 seq_printf(m, "\tSubmissions: %llu %s\n",
Dave Gordonc18468c2016-08-09 15:19:22 +01002509 submissions, engine->name);
Dave Gordon8b417c22015-08-12 15:43:44 +01002510 }
2511 seq_printf(m, "\tTotal: %llu\n", tot);
2512}
2513
Oscar Mateoa8b93702017-05-10 15:04:51 +00002514static bool check_guc_submission(struct seq_file *m)
Dave Gordon8b417c22015-08-12 15:43:44 +01002515{
David Weinehall36cdd012016-08-22 13:59:31 +03002516 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Chris Wilson334636c2016-11-29 12:10:20 +00002517 const struct intel_guc *guc = &dev_priv->guc;
Dave Gordon8b417c22015-08-12 15:43:44 +01002518
Chris Wilson334636c2016-11-29 12:10:20 +00002519 if (!guc->execbuf_client) {
2520 seq_printf(m, "GuC submission %s\n",
2521 HAS_GUC_SCHED(dev_priv) ?
2522 "disabled" :
2523 "not supported");
Oscar Mateoa8b93702017-05-10 15:04:51 +00002524 return false;
Chris Wilson334636c2016-11-29 12:10:20 +00002525 }
Dave Gordon8b417c22015-08-12 15:43:44 +01002526
Oscar Mateoa8b93702017-05-10 15:04:51 +00002527 return true;
2528}
2529
Dave Gordon8b417c22015-08-12 15:43:44 +01002530static int i915_guc_info(struct seq_file *m, void *data)
2531{
2532 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2533 const struct intel_guc *guc = &dev_priv->guc;
Dave Gordon8b417c22015-08-12 15:43:44 +01002534
Oscar Mateoa8b93702017-05-10 15:04:51 +00002535 if (!check_guc_submission(m))
Dave Gordon8b417c22015-08-12 15:43:44 +01002536 return 0;
Dave Gordon8b417c22015-08-12 15:43:44 +01002537
Dave Gordon9636f6d2016-06-13 17:57:28 +01002538 seq_printf(m, "Doorbell map:\n");
Joonas Lahtinenabddffd2017-03-22 10:39:44 -07002539 seq_printf(m, "\t%*pb\n", GUC_NUM_DOORBELLS, guc->doorbell_bitmap);
Chris Wilson334636c2016-11-29 12:10:20 +00002540 seq_printf(m, "Doorbell next cacheline: 0x%x\n\n", guc->db_cacheline);
Dave Gordon9636f6d2016-06-13 17:57:28 +01002541
Chris Wilson334636c2016-11-29 12:10:20 +00002542 seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client);
2543 i915_guc_client_info(m, dev_priv, guc->execbuf_client);
Dave Gordon8b417c22015-08-12 15:43:44 +01002544
Akash Goel5aa1ee42016-10-12 21:54:36 +05302545 i915_guc_log_info(m, dev_priv);
2546
Dave Gordon8b417c22015-08-12 15:43:44 +01002547 /* Add more as required ... */
2548
2549 return 0;
2550}
2551
Oscar Mateoa8b93702017-05-10 15:04:51 +00002552static int i915_guc_stage_pool(struct seq_file *m, void *data)
Alex Dai4c7e77f2015-08-12 15:43:40 +01002553{
David Weinehall36cdd012016-08-22 13:59:31 +03002554 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Oscar Mateoa8b93702017-05-10 15:04:51 +00002555 const struct intel_guc *guc = &dev_priv->guc;
2556 struct guc_stage_desc *desc = guc->stage_desc_pool_vaddr;
2557 struct i915_guc_client *client = guc->execbuf_client;
2558 unsigned int tmp;
2559 int index;
Alex Dai4c7e77f2015-08-12 15:43:40 +01002560
Oscar Mateoa8b93702017-05-10 15:04:51 +00002561 if (!check_guc_submission(m))
Alex Dai4c7e77f2015-08-12 15:43:40 +01002562 return 0;
2563
Oscar Mateoa8b93702017-05-10 15:04:51 +00002564 for (index = 0; index < GUC_MAX_STAGE_DESCRIPTORS; index++, desc++) {
2565 struct intel_engine_cs *engine;
Alex Dai4c7e77f2015-08-12 15:43:40 +01002566
Oscar Mateoa8b93702017-05-10 15:04:51 +00002567 if (!(desc->attribute & GUC_STAGE_DESC_ATTR_ACTIVE))
2568 continue;
Alex Dai4c7e77f2015-08-12 15:43:40 +01002569
Oscar Mateoa8b93702017-05-10 15:04:51 +00002570 seq_printf(m, "GuC stage descriptor %u:\n", index);
2571 seq_printf(m, "\tIndex: %u\n", desc->stage_id);
2572 seq_printf(m, "\tAttribute: 0x%x\n", desc->attribute);
2573 seq_printf(m, "\tPriority: %d\n", desc->priority);
2574 seq_printf(m, "\tDoorbell id: %d\n", desc->db_id);
2575 seq_printf(m, "\tEngines used: 0x%x\n",
2576 desc->engines_used);
2577 seq_printf(m, "\tDoorbell trigger phy: 0x%llx, cpu: 0x%llx, uK: 0x%x\n",
2578 desc->db_trigger_phy,
2579 desc->db_trigger_cpu,
2580 desc->db_trigger_uk);
2581 seq_printf(m, "\tProcess descriptor: 0x%x\n",
2582 desc->process_desc);
Colin Ian King9a094852017-05-16 10:22:35 +01002583 seq_printf(m, "\tWorkqueue address: 0x%x, size: 0x%x\n",
Oscar Mateoa8b93702017-05-10 15:04:51 +00002584 desc->wq_addr, desc->wq_size);
2585 seq_putc(m, '\n');
2586
2587 for_each_engine_masked(engine, dev_priv, client->engines, tmp) {
2588 u32 guc_engine_id = engine->guc_id;
2589 struct guc_execlist_context *lrc =
2590 &desc->lrc[guc_engine_id];
2591
2592 seq_printf(m, "\t%s LRC:\n", engine->name);
2593 seq_printf(m, "\t\tContext desc: 0x%x\n",
2594 lrc->context_desc);
2595 seq_printf(m, "\t\tContext id: 0x%x\n", lrc->context_id);
2596 seq_printf(m, "\t\tLRCA: 0x%x\n", lrc->ring_lrca);
2597 seq_printf(m, "\t\tRing begin: 0x%x\n", lrc->ring_begin);
2598 seq_printf(m, "\t\tRing end: 0x%x\n", lrc->ring_end);
2599 seq_putc(m, '\n');
2600 }
Alex Dai4c7e77f2015-08-12 15:43:40 +01002601 }
2602
Oscar Mateoa8b93702017-05-10 15:04:51 +00002603 return 0;
2604}
2605
Alex Dai4c7e77f2015-08-12 15:43:40 +01002606static int i915_guc_log_dump(struct seq_file *m, void *data)
2607{
Daniele Ceraolo Spurioac58d2a2017-05-22 10:50:28 -07002608 struct drm_info_node *node = m->private;
2609 struct drm_i915_private *dev_priv = node_to_i915(node);
2610 bool dump_load_err = !!node->info_ent->data;
2611 struct drm_i915_gem_object *obj = NULL;
2612 u32 *log;
2613 int i = 0;
Alex Dai4c7e77f2015-08-12 15:43:40 +01002614
Daniele Ceraolo Spurioac58d2a2017-05-22 10:50:28 -07002615 if (dump_load_err)
2616 obj = dev_priv->guc.load_err_log;
2617 else if (dev_priv->guc.log.vma)
2618 obj = dev_priv->guc.log.vma->obj;
2619
2620 if (!obj)
Alex Dai4c7e77f2015-08-12 15:43:40 +01002621 return 0;
2622
Daniele Ceraolo Spurioac58d2a2017-05-22 10:50:28 -07002623 log = i915_gem_object_pin_map(obj, I915_MAP_WC);
2624 if (IS_ERR(log)) {
2625 DRM_DEBUG("Failed to pin object\n");
2626 seq_puts(m, "(log data unaccessible)\n");
2627 return PTR_ERR(log);
Alex Dai4c7e77f2015-08-12 15:43:40 +01002628 }
2629
Daniele Ceraolo Spurioac58d2a2017-05-22 10:50:28 -07002630 for (i = 0; i < obj->base.size / sizeof(u32); i += 4)
2631 seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n",
2632 *(log + i), *(log + i + 1),
2633 *(log + i + 2), *(log + i + 3));
2634
Alex Dai4c7e77f2015-08-12 15:43:40 +01002635 seq_putc(m, '\n');
2636
Daniele Ceraolo Spurioac58d2a2017-05-22 10:50:28 -07002637 i915_gem_object_unpin_map(obj);
2638
Alex Dai4c7e77f2015-08-12 15:43:40 +01002639 return 0;
2640}
2641
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05302642static int i915_guc_log_control_get(void *data, u64 *val)
2643{
Chris Wilsonbcc36d82017-04-07 20:42:20 +01002644 struct drm_i915_private *dev_priv = data;
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05302645
2646 if (!dev_priv->guc.log.vma)
2647 return -EINVAL;
2648
Michal Wajdeczko4f044a82017-09-19 19:38:44 +00002649 *val = i915_modparams.guc_log_level;
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05302650
2651 return 0;
2652}
2653
2654static int i915_guc_log_control_set(void *data, u64 val)
2655{
Chris Wilsonbcc36d82017-04-07 20:42:20 +01002656 struct drm_i915_private *dev_priv = data;
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05302657 int ret;
2658
2659 if (!dev_priv->guc.log.vma)
2660 return -EINVAL;
2661
Chris Wilsonbcc36d82017-04-07 20:42:20 +01002662 ret = mutex_lock_interruptible(&dev_priv->drm.struct_mutex);
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05302663 if (ret)
2664 return ret;
2665
2666 intel_runtime_pm_get(dev_priv);
2667 ret = i915_guc_log_control(dev_priv, val);
2668 intel_runtime_pm_put(dev_priv);
2669
Chris Wilsonbcc36d82017-04-07 20:42:20 +01002670 mutex_unlock(&dev_priv->drm.struct_mutex);
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05302671 return ret;
2672}
2673
2674DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_control_fops,
2675 i915_guc_log_control_get, i915_guc_log_control_set,
2676 "%lld\n");
2677
Chris Wilsonb86bef202017-01-16 13:06:21 +00002678static const char *psr2_live_status(u32 val)
2679{
2680 static const char * const live_status[] = {
2681 "IDLE",
2682 "CAPTURE",
2683 "CAPTURE_FS",
2684 "SLEEP",
2685 "BUFON_FW",
2686 "ML_UP",
2687 "SU_STANDBY",
2688 "FAST_SLEEP",
2689 "DEEP_SLEEP",
2690 "BUF_ON",
2691 "TG_ON"
2692 };
2693
2694 val = (val & EDP_PSR2_STATUS_STATE_MASK) >> EDP_PSR2_STATUS_STATE_SHIFT;
2695 if (val < ARRAY_SIZE(live_status))
2696 return live_status[val];
2697
2698 return "unknown";
2699}
2700
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002701static int i915_edp_psr_status(struct seq_file *m, void *data)
2702{
David Weinehall36cdd012016-08-22 13:59:31 +03002703 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Rodrigo Vivia031d702013-10-03 16:15:06 -03002704 u32 psrperf = 0;
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002705 u32 stat[3];
2706 enum pipe pipe;
Rodrigo Vivia031d702013-10-03 16:15:06 -03002707 bool enabled = false;
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002708
David Weinehall36cdd012016-08-22 13:59:31 +03002709 if (!HAS_PSR(dev_priv)) {
Damien Lespiau3553a8e2015-03-09 14:17:58 +00002710 seq_puts(m, "PSR not supported\n");
2711 return 0;
2712 }
2713
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002714 intel_runtime_pm_get(dev_priv);
2715
Daniel Vetterfa128fa2014-07-11 10:30:17 -07002716 mutex_lock(&dev_priv->psr.lock);
Rodrigo Vivia031d702013-10-03 16:15:06 -03002717 seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support));
2718 seq_printf(m, "Source_OK: %s\n", yesno(dev_priv->psr.source_ok));
Daniel Vetter2807cf62014-07-11 10:30:11 -07002719 seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled));
Rodrigo Vivi5755c782014-06-12 10:16:45 -07002720 seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active));
Daniel Vetterfa128fa2014-07-11 10:30:17 -07002721 seq_printf(m, "Busy frontbuffer bits: 0x%03x\n",
2722 dev_priv->psr.busy_frontbuffer_bits);
2723 seq_printf(m, "Re-enable work scheduled: %s\n",
2724 yesno(work_busy(&dev_priv->psr.work.work)));
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002725
Nagaraju, Vathsala7e3eb592016-12-09 23:42:09 +05302726 if (HAS_DDI(dev_priv)) {
2727 if (dev_priv->psr.psr2_support)
2728 enabled = I915_READ(EDP_PSR2_CTL) & EDP_PSR2_ENABLE;
2729 else
2730 enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE;
2731 } else {
Damien Lespiau3553a8e2015-03-09 14:17:58 +00002732 for_each_pipe(dev_priv, pipe) {
Chris Wilson9c870d02016-10-24 13:42:15 +01002733 enum transcoder cpu_transcoder =
2734 intel_pipe_to_cpu_transcoder(dev_priv, pipe);
2735 enum intel_display_power_domain power_domain;
2736
2737 power_domain = POWER_DOMAIN_TRANSCODER(cpu_transcoder);
2738 if (!intel_display_power_get_if_enabled(dev_priv,
2739 power_domain))
2740 continue;
2741
Damien Lespiau3553a8e2015-03-09 14:17:58 +00002742 stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) &
2743 VLV_EDP_PSR_CURR_STATE_MASK;
2744 if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) ||
2745 (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE))
2746 enabled = true;
Chris Wilson9c870d02016-10-24 13:42:15 +01002747
2748 intel_display_power_put(dev_priv, power_domain);
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002749 }
2750 }
Rodrigo Vivi60e5ffe2016-02-01 12:02:07 -08002751
2752 seq_printf(m, "Main link in standby mode: %s\n",
2753 yesno(dev_priv->psr.link_standby));
2754
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002755 seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled));
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002756
David Weinehall36cdd012016-08-22 13:59:31 +03002757 if (!HAS_DDI(dev_priv))
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002758 for_each_pipe(dev_priv, pipe) {
2759 if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) ||
2760 (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE))
2761 seq_printf(m, " pipe %c", pipe_name(pipe));
2762 }
2763 seq_puts(m, "\n");
2764
Rodrigo Vivi05eec3c2015-11-23 14:16:40 -08002765 /*
2766 * VLV/CHV PSR has no kind of performance counter
2767 * SKL+ Perf counter is reset to 0 everytime DC state is entered
2768 */
David Weinehall36cdd012016-08-22 13:59:31 +03002769 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
Ville Syrjälä443a3892015-11-11 20:34:15 +02002770 psrperf = I915_READ(EDP_PSR_PERF_CNT) &
Rodrigo Vivia031d702013-10-03 16:15:06 -03002771 EDP_PSR_PERF_CNT_MASK;
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002772
2773 seq_printf(m, "Performance_Counter: %u\n", psrperf);
2774 }
Nagaraju, Vathsala6ba1f9e2017-01-06 22:02:32 +05302775 if (dev_priv->psr.psr2_support) {
Chris Wilsonb86bef202017-01-16 13:06:21 +00002776 u32 psr2 = I915_READ(EDP_PSR2_STATUS_CTL);
Nagaraju, Vathsala6ba1f9e2017-01-06 22:02:32 +05302777
Chris Wilsonb86bef202017-01-16 13:06:21 +00002778 seq_printf(m, "EDP_PSR2_STATUS_CTL: %x [%s]\n",
2779 psr2, psr2_live_status(psr2));
Nagaraju, Vathsala6ba1f9e2017-01-06 22:02:32 +05302780 }
Daniel Vetterfa128fa2014-07-11 10:30:17 -07002781 mutex_unlock(&dev_priv->psr.lock);
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002782
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002783 intel_runtime_pm_put(dev_priv);
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002784 return 0;
2785}
2786
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002787static int i915_sink_crc(struct seq_file *m, void *data)
2788{
David Weinehall36cdd012016-08-22 13:59:31 +03002789 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2790 struct drm_device *dev = &dev_priv->drm;
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002791 struct intel_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01002792 struct drm_connector_list_iter conn_iter;
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002793 struct intel_dp *intel_dp = NULL;
2794 int ret;
2795 u8 crc[6];
2796
2797 drm_modeset_lock_all(dev);
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01002798 drm_connector_list_iter_begin(dev, &conn_iter);
2799 for_each_intel_connector_iter(connector, &conn_iter) {
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002800 struct drm_crtc *crtc;
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002801
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002802 if (!connector->base.state->best_encoder)
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002803 continue;
2804
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002805 crtc = connector->base.state->crtc;
2806 if (!crtc->state->active)
Paulo Zanonib6ae3c72014-02-13 17:51:33 -02002807 continue;
2808
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002809 if (connector->base.connector_type != DRM_MODE_CONNECTOR_eDP)
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002810 continue;
2811
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002812 intel_dp = enc_to_intel_dp(connector->base.state->best_encoder);
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002813
2814 ret = intel_dp_sink_crc(intel_dp, crc);
2815 if (ret)
2816 goto out;
2817
2818 seq_printf(m, "%02x%02x%02x%02x%02x%02x\n",
2819 crc[0], crc[1], crc[2],
2820 crc[3], crc[4], crc[5]);
2821 goto out;
2822 }
2823 ret = -ENODEV;
2824out:
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01002825 drm_connector_list_iter_end(&conn_iter);
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002826 drm_modeset_unlock_all(dev);
2827 return ret;
2828}
2829
Jesse Barnesec013e72013-08-20 10:29:23 +01002830static int i915_energy_uJ(struct seq_file *m, void *data)
2831{
David Weinehall36cdd012016-08-22 13:59:31 +03002832 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Gabriel Krisman Bertazid38014e2017-07-26 02:30:16 -03002833 unsigned long long power;
Jesse Barnesec013e72013-08-20 10:29:23 +01002834 u32 units;
2835
David Weinehall36cdd012016-08-22 13:59:31 +03002836 if (INTEL_GEN(dev_priv) < 6)
Jesse Barnesec013e72013-08-20 10:29:23 +01002837 return -ENODEV;
2838
Paulo Zanoni36623ef2014-02-21 13:52:23 -03002839 intel_runtime_pm_get(dev_priv);
2840
Gabriel Krisman Bertazid38014e2017-07-26 02:30:16 -03002841 if (rdmsrl_safe(MSR_RAPL_POWER_UNIT, &power)) {
2842 intel_runtime_pm_put(dev_priv);
2843 return -ENODEV;
2844 }
2845
2846 units = (power & 0x1f00) >> 8;
Jesse Barnesec013e72013-08-20 10:29:23 +01002847 power = I915_READ(MCH_SECP_NRG_STTS);
Gabriel Krisman Bertazid38014e2017-07-26 02:30:16 -03002848 power = (1000000 * power) >> units; /* convert to uJ */
Jesse Barnesec013e72013-08-20 10:29:23 +01002849
Paulo Zanoni36623ef2014-02-21 13:52:23 -03002850 intel_runtime_pm_put(dev_priv);
2851
Gabriel Krisman Bertazid38014e2017-07-26 02:30:16 -03002852 seq_printf(m, "%llu", power);
Paulo Zanoni371db662013-08-19 13:18:10 -03002853
2854 return 0;
2855}
2856
Damien Lespiau6455c872015-06-04 18:23:57 +01002857static int i915_runtime_pm_status(struct seq_file *m, void *unused)
Paulo Zanoni371db662013-08-19 13:18:10 -03002858{
David Weinehall36cdd012016-08-22 13:59:31 +03002859 struct drm_i915_private *dev_priv = node_to_i915(m->private);
David Weinehall52a05c32016-08-22 13:32:44 +03002860 struct pci_dev *pdev = dev_priv->drm.pdev;
Paulo Zanoni371db662013-08-19 13:18:10 -03002861
Chris Wilsona156e642016-04-03 14:14:21 +01002862 if (!HAS_RUNTIME_PM(dev_priv))
2863 seq_puts(m, "Runtime power management not supported\n");
Paulo Zanoni371db662013-08-19 13:18:10 -03002864
Chris Wilson67d97da2016-07-04 08:08:31 +01002865 seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->gt.awake));
Paulo Zanoni371db662013-08-19 13:18:10 -03002866 seq_printf(m, "IRQs disabled: %s\n",
Jesse Barnes9df7575f2014-06-20 09:29:20 -07002867 yesno(!intel_irqs_enabled(dev_priv)));
Chris Wilson0d804182015-06-15 12:52:28 +01002868#ifdef CONFIG_PM
Damien Lespiaua6aaec82015-06-04 18:23:58 +01002869 seq_printf(m, "Usage count: %d\n",
David Weinehall36cdd012016-08-22 13:59:31 +03002870 atomic_read(&dev_priv->drm.dev->power.usage_count));
Chris Wilson0d804182015-06-15 12:52:28 +01002871#else
2872 seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n");
2873#endif
Chris Wilsona156e642016-04-03 14:14:21 +01002874 seq_printf(m, "PCI device power state: %s [%d]\n",
David Weinehall52a05c32016-08-22 13:32:44 +03002875 pci_power_name(pdev->current_state),
2876 pdev->current_state);
Paulo Zanoni371db662013-08-19 13:18:10 -03002877
Jesse Barnesec013e72013-08-20 10:29:23 +01002878 return 0;
2879}
2880
Imre Deak1da51582013-11-25 17:15:35 +02002881static int i915_power_domain_info(struct seq_file *m, void *unused)
2882{
David Weinehall36cdd012016-08-22 13:59:31 +03002883 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Imre Deak1da51582013-11-25 17:15:35 +02002884 struct i915_power_domains *power_domains = &dev_priv->power_domains;
2885 int i;
2886
2887 mutex_lock(&power_domains->lock);
2888
2889 seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count");
2890 for (i = 0; i < power_domains->power_well_count; i++) {
2891 struct i915_power_well *power_well;
2892 enum intel_display_power_domain power_domain;
2893
2894 power_well = &power_domains->power_wells[i];
2895 seq_printf(m, "%-25s %d\n", power_well->name,
2896 power_well->count);
2897
Joonas Lahtinen8385c2e2017-02-08 15:12:10 +02002898 for_each_power_domain(power_domain, power_well->domains)
Imre Deak1da51582013-11-25 17:15:35 +02002899 seq_printf(m, " %-23s %d\n",
Daniel Stone9895ad02015-11-20 15:55:33 +00002900 intel_display_power_domain_str(power_domain),
Imre Deak1da51582013-11-25 17:15:35 +02002901 power_domains->domain_use_count[power_domain]);
Imre Deak1da51582013-11-25 17:15:35 +02002902 }
2903
2904 mutex_unlock(&power_domains->lock);
2905
2906 return 0;
2907}
2908
Damien Lespiaub7cec662015-10-27 14:47:01 +02002909static int i915_dmc_info(struct seq_file *m, void *unused)
2910{
David Weinehall36cdd012016-08-22 13:59:31 +03002911 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Damien Lespiaub7cec662015-10-27 14:47:01 +02002912 struct intel_csr *csr;
2913
David Weinehall36cdd012016-08-22 13:59:31 +03002914 if (!HAS_CSR(dev_priv)) {
Damien Lespiaub7cec662015-10-27 14:47:01 +02002915 seq_puts(m, "not supported\n");
2916 return 0;
2917 }
2918
2919 csr = &dev_priv->csr;
2920
Mika Kuoppala6fb403d2015-10-30 17:54:47 +02002921 intel_runtime_pm_get(dev_priv);
2922
Damien Lespiaub7cec662015-10-27 14:47:01 +02002923 seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL));
2924 seq_printf(m, "path: %s\n", csr->fw_path);
2925
2926 if (!csr->dmc_payload)
Mika Kuoppala6fb403d2015-10-30 17:54:47 +02002927 goto out;
Damien Lespiaub7cec662015-10-27 14:47:01 +02002928
2929 seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version),
2930 CSR_VERSION_MINOR(csr->version));
2931
Mika Kuoppala48de5682017-05-09 13:05:22 +03002932 if (IS_KABYLAKE(dev_priv) ||
2933 (IS_SKYLAKE(dev_priv) && csr->version >= CSR_VERSION(1, 6))) {
Damien Lespiau83372062015-10-30 17:53:32 +02002934 seq_printf(m, "DC3 -> DC5 count: %d\n",
2935 I915_READ(SKL_CSR_DC3_DC5_COUNT));
2936 seq_printf(m, "DC5 -> DC6 count: %d\n",
2937 I915_READ(SKL_CSR_DC5_DC6_COUNT));
David Weinehall36cdd012016-08-22 13:59:31 +03002938 } else if (IS_BROXTON(dev_priv) && csr->version >= CSR_VERSION(1, 4)) {
Mika Kuoppala16e11b92015-10-27 14:47:03 +02002939 seq_printf(m, "DC3 -> DC5 count: %d\n",
2940 I915_READ(BXT_CSR_DC3_DC5_COUNT));
Damien Lespiau83372062015-10-30 17:53:32 +02002941 }
2942
Mika Kuoppala6fb403d2015-10-30 17:54:47 +02002943out:
2944 seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0)));
2945 seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE));
2946 seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL));
2947
Damien Lespiau83372062015-10-30 17:53:32 +02002948 intel_runtime_pm_put(dev_priv);
2949
Damien Lespiaub7cec662015-10-27 14:47:01 +02002950 return 0;
2951}
2952
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002953static void intel_seq_print_mode(struct seq_file *m, int tabs,
2954 struct drm_display_mode *mode)
2955{
2956 int i;
2957
2958 for (i = 0; i < tabs; i++)
2959 seq_putc(m, '\t');
2960
2961 seq_printf(m, "id %d:\"%s\" freq %d clock %d hdisp %d hss %d hse %d htot %d vdisp %d vss %d vse %d vtot %d type 0x%x flags 0x%x\n",
2962 mode->base.id, mode->name,
2963 mode->vrefresh, mode->clock,
2964 mode->hdisplay, mode->hsync_start,
2965 mode->hsync_end, mode->htotal,
2966 mode->vdisplay, mode->vsync_start,
2967 mode->vsync_end, mode->vtotal,
2968 mode->type, mode->flags);
2969}
2970
2971static void intel_encoder_info(struct seq_file *m,
2972 struct intel_crtc *intel_crtc,
2973 struct intel_encoder *intel_encoder)
2974{
David Weinehall36cdd012016-08-22 13:59:31 +03002975 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2976 struct drm_device *dev = &dev_priv->drm;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002977 struct drm_crtc *crtc = &intel_crtc->base;
2978 struct intel_connector *intel_connector;
2979 struct drm_encoder *encoder;
2980
2981 encoder = &intel_encoder->base;
2982 seq_printf(m, "\tencoder %d: type: %s, connectors:\n",
Jani Nikula8e329a032014-06-03 14:56:21 +03002983 encoder->base.id, encoder->name);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002984 for_each_connector_on_encoder(dev, encoder, intel_connector) {
2985 struct drm_connector *connector = &intel_connector->base;
2986 seq_printf(m, "\t\tconnector %d: type: %s, status: %s",
2987 connector->base.id,
Jani Nikulac23cc412014-06-03 14:56:17 +03002988 connector->name,
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002989 drm_get_connector_status_name(connector->status));
2990 if (connector->status == connector_status_connected) {
2991 struct drm_display_mode *mode = &crtc->mode;
2992 seq_printf(m, ", mode:\n");
2993 intel_seq_print_mode(m, 2, mode);
2994 } else {
2995 seq_putc(m, '\n');
2996 }
2997 }
2998}
2999
3000static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc)
3001{
David Weinehall36cdd012016-08-22 13:59:31 +03003002 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3003 struct drm_device *dev = &dev_priv->drm;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003004 struct drm_crtc *crtc = &intel_crtc->base;
3005 struct intel_encoder *intel_encoder;
Maarten Lankhorst23a48d52015-09-10 16:07:57 +02003006 struct drm_plane_state *plane_state = crtc->primary->state;
3007 struct drm_framebuffer *fb = plane_state->fb;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003008
Maarten Lankhorst23a48d52015-09-10 16:07:57 +02003009 if (fb)
Matt Roper5aa8a932014-06-16 10:12:55 -07003010 seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n",
Maarten Lankhorst23a48d52015-09-10 16:07:57 +02003011 fb->base.id, plane_state->src_x >> 16,
3012 plane_state->src_y >> 16, fb->width, fb->height);
Matt Roper5aa8a932014-06-16 10:12:55 -07003013 else
3014 seq_puts(m, "\tprimary plane disabled\n");
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003015 for_each_encoder_on_crtc(dev, crtc, intel_encoder)
3016 intel_encoder_info(m, intel_crtc, intel_encoder);
3017}
3018
3019static void intel_panel_info(struct seq_file *m, struct intel_panel *panel)
3020{
3021 struct drm_display_mode *mode = panel->fixed_mode;
3022
3023 seq_printf(m, "\tfixed mode:\n");
3024 intel_seq_print_mode(m, 2, mode);
3025}
3026
3027static void intel_dp_info(struct seq_file *m,
3028 struct intel_connector *intel_connector)
3029{
3030 struct intel_encoder *intel_encoder = intel_connector->encoder;
3031 struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base);
3032
3033 seq_printf(m, "\tDPCD rev: %x\n", intel_dp->dpcd[DP_DPCD_REV]);
Jani Nikula742f4912015-09-03 11:16:09 +03003034 seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio));
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003035 if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP)
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003036 intel_panel_info(m, &intel_connector->panel);
Mika Kahola80209e52016-09-09 14:10:57 +03003037
3038 drm_dp_downstream_debug(m, intel_dp->dpcd, intel_dp->downstream_ports,
3039 &intel_dp->aux);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003040}
3041
Libin Yang9a148a92016-11-28 20:07:05 +08003042static void intel_dp_mst_info(struct seq_file *m,
3043 struct intel_connector *intel_connector)
3044{
3045 struct intel_encoder *intel_encoder = intel_connector->encoder;
3046 struct intel_dp_mst_encoder *intel_mst =
3047 enc_to_mst(&intel_encoder->base);
3048 struct intel_digital_port *intel_dig_port = intel_mst->primary;
3049 struct intel_dp *intel_dp = &intel_dig_port->dp;
3050 bool has_audio = drm_dp_mst_port_has_audio(&intel_dp->mst_mgr,
3051 intel_connector->port);
3052
3053 seq_printf(m, "\taudio support: %s\n", yesno(has_audio));
3054}
3055
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003056static void intel_hdmi_info(struct seq_file *m,
3057 struct intel_connector *intel_connector)
3058{
3059 struct intel_encoder *intel_encoder = intel_connector->encoder;
3060 struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base);
3061
Jani Nikula742f4912015-09-03 11:16:09 +03003062 seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio));
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003063}
3064
3065static void intel_lvds_info(struct seq_file *m,
3066 struct intel_connector *intel_connector)
3067{
3068 intel_panel_info(m, &intel_connector->panel);
3069}
3070
3071static void intel_connector_info(struct seq_file *m,
3072 struct drm_connector *connector)
3073{
3074 struct intel_connector *intel_connector = to_intel_connector(connector);
3075 struct intel_encoder *intel_encoder = intel_connector->encoder;
Jesse Barnesf103fc72014-02-20 12:39:57 -08003076 struct drm_display_mode *mode;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003077
3078 seq_printf(m, "connector %d: type %s, status: %s\n",
Jani Nikulac23cc412014-06-03 14:56:17 +03003079 connector->base.id, connector->name,
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003080 drm_get_connector_status_name(connector->status));
3081 if (connector->status == connector_status_connected) {
3082 seq_printf(m, "\tname: %s\n", connector->display_info.name);
3083 seq_printf(m, "\tphysical dimensions: %dx%dmm\n",
3084 connector->display_info.width_mm,
3085 connector->display_info.height_mm);
3086 seq_printf(m, "\tsubpixel order: %s\n",
3087 drm_get_subpixel_order_name(connector->display_info.subpixel_order));
3088 seq_printf(m, "\tCEA rev: %d\n",
3089 connector->display_info.cea_rev);
3090 }
Maarten Lankhorstee648a72016-06-21 12:00:38 +02003091
Maarten Lankhorst77d1f612017-06-26 10:33:49 +02003092 if (!intel_encoder)
Maarten Lankhorstee648a72016-06-21 12:00:38 +02003093 return;
3094
3095 switch (connector->connector_type) {
3096 case DRM_MODE_CONNECTOR_DisplayPort:
3097 case DRM_MODE_CONNECTOR_eDP:
Libin Yang9a148a92016-11-28 20:07:05 +08003098 if (intel_encoder->type == INTEL_OUTPUT_DP_MST)
3099 intel_dp_mst_info(m, intel_connector);
3100 else
3101 intel_dp_info(m, intel_connector);
Maarten Lankhorstee648a72016-06-21 12:00:38 +02003102 break;
3103 case DRM_MODE_CONNECTOR_LVDS:
3104 if (intel_encoder->type == INTEL_OUTPUT_LVDS)
Dave Airlie36cd7442014-05-02 13:44:18 +10003105 intel_lvds_info(m, intel_connector);
Maarten Lankhorstee648a72016-06-21 12:00:38 +02003106 break;
3107 case DRM_MODE_CONNECTOR_HDMIA:
3108 if (intel_encoder->type == INTEL_OUTPUT_HDMI ||
3109 intel_encoder->type == INTEL_OUTPUT_UNKNOWN)
3110 intel_hdmi_info(m, intel_connector);
3111 break;
3112 default:
3113 break;
Dave Airlie36cd7442014-05-02 13:44:18 +10003114 }
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003115
Jesse Barnesf103fc72014-02-20 12:39:57 -08003116 seq_printf(m, "\tmodes:\n");
3117 list_for_each_entry(mode, &connector->modes, head)
3118 intel_seq_print_mode(m, 2, mode);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003119}
3120
Robert Fekete3abc4e02015-10-27 16:58:32 +01003121static const char *plane_type(enum drm_plane_type type)
3122{
3123 switch (type) {
3124 case DRM_PLANE_TYPE_OVERLAY:
3125 return "OVL";
3126 case DRM_PLANE_TYPE_PRIMARY:
3127 return "PRI";
3128 case DRM_PLANE_TYPE_CURSOR:
3129 return "CUR";
3130 /*
3131 * Deliberately omitting default: to generate compiler warnings
3132 * when a new drm_plane_type gets added.
3133 */
3134 }
3135
3136 return "unknown";
3137}
3138
3139static const char *plane_rotation(unsigned int rotation)
3140{
3141 static char buf[48];
3142 /*
Robert Fossc2c446a2017-05-19 16:50:17 -04003143 * According to doc only one DRM_MODE_ROTATE_ is allowed but this
Robert Fekete3abc4e02015-10-27 16:58:32 +01003144 * will print them all to visualize if the values are misused
3145 */
3146 snprintf(buf, sizeof(buf),
3147 "%s%s%s%s%s%s(0x%08x)",
Robert Fossc2c446a2017-05-19 16:50:17 -04003148 (rotation & DRM_MODE_ROTATE_0) ? "0 " : "",
3149 (rotation & DRM_MODE_ROTATE_90) ? "90 " : "",
3150 (rotation & DRM_MODE_ROTATE_180) ? "180 " : "",
3151 (rotation & DRM_MODE_ROTATE_270) ? "270 " : "",
3152 (rotation & DRM_MODE_REFLECT_X) ? "FLIPX " : "",
3153 (rotation & DRM_MODE_REFLECT_Y) ? "FLIPY " : "",
Robert Fekete3abc4e02015-10-27 16:58:32 +01003154 rotation);
3155
3156 return buf;
3157}
3158
3159static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc)
3160{
David Weinehall36cdd012016-08-22 13:59:31 +03003161 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3162 struct drm_device *dev = &dev_priv->drm;
Robert Fekete3abc4e02015-10-27 16:58:32 +01003163 struct intel_plane *intel_plane;
3164
3165 for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {
3166 struct drm_plane_state *state;
3167 struct drm_plane *plane = &intel_plane->base;
Eric Engestromb3c11ac2016-11-12 01:12:56 +00003168 struct drm_format_name_buf format_name;
Robert Fekete3abc4e02015-10-27 16:58:32 +01003169
3170 if (!plane->state) {
3171 seq_puts(m, "plane->state is NULL!\n");
3172 continue;
3173 }
3174
3175 state = plane->state;
3176
Eric Engestrom90844f02016-08-15 01:02:38 +01003177 if (state->fb) {
Ville Syrjälä438b74a2016-12-14 23:32:55 +02003178 drm_get_format_name(state->fb->format->format,
3179 &format_name);
Eric Engestrom90844f02016-08-15 01:02:38 +01003180 } else {
Eric Engestromb3c11ac2016-11-12 01:12:56 +00003181 sprintf(format_name.str, "N/A");
Eric Engestrom90844f02016-08-15 01:02:38 +01003182 }
3183
Robert Fekete3abc4e02015-10-27 16:58:32 +01003184 seq_printf(m, "\t--Plane id %d: type=%s, crtc_pos=%4dx%4d, crtc_size=%4dx%4d, src_pos=%d.%04ux%d.%04u, src_size=%d.%04ux%d.%04u, format=%s, rotation=%s\n",
3185 plane->base.id,
3186 plane_type(intel_plane->base.type),
3187 state->crtc_x, state->crtc_y,
3188 state->crtc_w, state->crtc_h,
3189 (state->src_x >> 16),
3190 ((state->src_x & 0xffff) * 15625) >> 10,
3191 (state->src_y >> 16),
3192 ((state->src_y & 0xffff) * 15625) >> 10,
3193 (state->src_w >> 16),
3194 ((state->src_w & 0xffff) * 15625) >> 10,
3195 (state->src_h >> 16),
3196 ((state->src_h & 0xffff) * 15625) >> 10,
Eric Engestromb3c11ac2016-11-12 01:12:56 +00003197 format_name.str,
Robert Fekete3abc4e02015-10-27 16:58:32 +01003198 plane_rotation(state->rotation));
3199 }
3200}
3201
3202static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc)
3203{
3204 struct intel_crtc_state *pipe_config;
3205 int num_scalers = intel_crtc->num_scalers;
3206 int i;
3207
3208 pipe_config = to_intel_crtc_state(intel_crtc->base.state);
3209
3210 /* Not all platformas have a scaler */
3211 if (num_scalers) {
3212 seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d",
3213 num_scalers,
3214 pipe_config->scaler_state.scaler_users,
3215 pipe_config->scaler_state.scaler_id);
3216
A.Sunil Kamath58415912016-11-20 23:20:26 +05303217 for (i = 0; i < num_scalers; i++) {
Robert Fekete3abc4e02015-10-27 16:58:32 +01003218 struct intel_scaler *sc =
3219 &pipe_config->scaler_state.scalers[i];
3220
3221 seq_printf(m, ", scalers[%d]: use=%s, mode=%x",
3222 i, yesno(sc->in_use), sc->mode);
3223 }
3224 seq_puts(m, "\n");
3225 } else {
3226 seq_puts(m, "\tNo scalers available on this platform\n");
3227 }
3228}
3229
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003230static int i915_display_info(struct seq_file *m, void *unused)
3231{
David Weinehall36cdd012016-08-22 13:59:31 +03003232 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3233 struct drm_device *dev = &dev_priv->drm;
Chris Wilson065f2ec2014-03-12 09:13:13 +00003234 struct intel_crtc *crtc;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003235 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003236 struct drm_connector_list_iter conn_iter;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003237
Paulo Zanonib0e5ddf2014-04-01 14:55:10 -03003238 intel_runtime_pm_get(dev_priv);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003239 seq_printf(m, "CRTC info\n");
3240 seq_printf(m, "---------\n");
Damien Lespiaud3fcc802014-05-13 23:32:22 +01003241 for_each_intel_crtc(dev, crtc) {
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003242 struct intel_crtc_state *pipe_config;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003243
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003244 drm_modeset_lock(&crtc->base.mutex, NULL);
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003245 pipe_config = to_intel_crtc_state(crtc->base.state);
3246
Robert Fekete3abc4e02015-10-27 16:58:32 +01003247 seq_printf(m, "CRTC %d: pipe: %c, active=%s, (size=%dx%d), dither=%s, bpp=%d\n",
Chris Wilson065f2ec2014-03-12 09:13:13 +00003248 crtc->base.base.id, pipe_name(crtc->pipe),
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003249 yesno(pipe_config->base.active),
Robert Fekete3abc4e02015-10-27 16:58:32 +01003250 pipe_config->pipe_src_w, pipe_config->pipe_src_h,
3251 yesno(pipe_config->dither), pipe_config->pipe_bpp);
3252
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003253 if (pipe_config->base.active) {
Ville Syrjäläcd5dcbf2017-03-27 21:55:35 +03003254 struct intel_plane *cursor =
3255 to_intel_plane(crtc->base.cursor);
3256
Chris Wilson065f2ec2014-03-12 09:13:13 +00003257 intel_crtc_info(m, crtc);
3258
Ville Syrjäläcd5dcbf2017-03-27 21:55:35 +03003259 seq_printf(m, "\tcursor visible? %s, position (%d, %d), size %dx%d, addr 0x%08x\n",
3260 yesno(cursor->base.state->visible),
3261 cursor->base.state->crtc_x,
3262 cursor->base.state->crtc_y,
3263 cursor->base.state->crtc_w,
3264 cursor->base.state->crtc_h,
3265 cursor->cursor.base);
Robert Fekete3abc4e02015-10-27 16:58:32 +01003266 intel_scaler_info(m, crtc);
3267 intel_plane_info(m, crtc);
Paulo Zanonia23dc652014-04-01 14:55:11 -03003268 }
Daniel Vettercace8412014-05-22 17:56:31 +02003269
3270 seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n",
3271 yesno(!crtc->cpu_fifo_underrun_disabled),
3272 yesno(!crtc->pch_fifo_underrun_disabled));
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003273 drm_modeset_unlock(&crtc->base.mutex);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003274 }
3275
3276 seq_printf(m, "\n");
3277 seq_printf(m, "Connector info\n");
3278 seq_printf(m, "--------------\n");
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003279 mutex_lock(&dev->mode_config.mutex);
3280 drm_connector_list_iter_begin(dev, &conn_iter);
3281 drm_for_each_connector_iter(connector, &conn_iter)
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003282 intel_connector_info(m, connector);
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003283 drm_connector_list_iter_end(&conn_iter);
3284 mutex_unlock(&dev->mode_config.mutex);
3285
Paulo Zanonib0e5ddf2014-04-01 14:55:10 -03003286 intel_runtime_pm_put(dev_priv);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003287
3288 return 0;
3289}
3290
Chris Wilson1b365952016-10-04 21:11:31 +01003291static int i915_engine_info(struct seq_file *m, void *unused)
3292{
3293 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3294 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +05303295 enum intel_engine_id id;
Chris Wilsonf636edb2017-10-09 12:02:57 +01003296 struct drm_printer p;
Chris Wilson1b365952016-10-04 21:11:31 +01003297
Chris Wilson9c870d02016-10-24 13:42:15 +01003298 intel_runtime_pm_get(dev_priv);
3299
Chris Wilsonf73b5672017-03-02 15:03:56 +00003300 seq_printf(m, "GT awake? %s\n",
3301 yesno(dev_priv->gt.awake));
3302 seq_printf(m, "Global active requests: %d\n",
3303 dev_priv->gt.active_requests);
3304
Chris Wilsonf636edb2017-10-09 12:02:57 +01003305 p = drm_seq_file_printer(m);
3306 for_each_engine(engine, dev_priv, id)
3307 intel_engine_dump(engine, &p);
Chris Wilson1b365952016-10-04 21:11:31 +01003308
Chris Wilson9c870d02016-10-24 13:42:15 +01003309 intel_runtime_pm_put(dev_priv);
3310
Chris Wilson1b365952016-10-04 21:11:31 +01003311 return 0;
3312}
3313
Ben Widawskye04934c2014-06-30 09:53:42 -07003314static int i915_semaphore_status(struct seq_file *m, void *unused)
3315{
David Weinehall36cdd012016-08-22 13:59:31 +03003316 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3317 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003318 struct intel_engine_cs *engine;
David Weinehall36cdd012016-08-22 13:59:31 +03003319 int num_rings = INTEL_INFO(dev_priv)->num_rings;
Dave Gordonc3232b12016-03-23 18:19:53 +00003320 enum intel_engine_id id;
3321 int j, ret;
Ben Widawskye04934c2014-06-30 09:53:42 -07003322
Michal Wajdeczko4f044a82017-09-19 19:38:44 +00003323 if (!i915_modparams.semaphores) {
Ben Widawskye04934c2014-06-30 09:53:42 -07003324 seq_puts(m, "Semaphores are disabled\n");
3325 return 0;
3326 }
3327
3328 ret = mutex_lock_interruptible(&dev->struct_mutex);
3329 if (ret)
3330 return ret;
Paulo Zanoni03872062014-07-09 14:31:57 -03003331 intel_runtime_pm_get(dev_priv);
Ben Widawskye04934c2014-06-30 09:53:42 -07003332
David Weinehall36cdd012016-08-22 13:59:31 +03003333 if (IS_BROADWELL(dev_priv)) {
Ben Widawskye04934c2014-06-30 09:53:42 -07003334 struct page *page;
3335 uint64_t *seqno;
3336
Chris Wilson51d545d2016-08-15 10:49:02 +01003337 page = i915_gem_object_get_page(dev_priv->semaphore->obj, 0);
Ben Widawskye04934c2014-06-30 09:53:42 -07003338
3339 seqno = (uint64_t *)kmap_atomic(page);
Akash Goel3b3f1652016-10-13 22:44:48 +05303340 for_each_engine(engine, dev_priv, id) {
Ben Widawskye04934c2014-06-30 09:53:42 -07003341 uint64_t offset;
3342
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003343 seq_printf(m, "%s\n", engine->name);
Ben Widawskye04934c2014-06-30 09:53:42 -07003344
3345 seq_puts(m, " Last signal:");
3346 for (j = 0; j < num_rings; j++) {
Dave Gordonc3232b12016-03-23 18:19:53 +00003347 offset = id * I915_NUM_ENGINES + j;
Ben Widawskye04934c2014-06-30 09:53:42 -07003348 seq_printf(m, "0x%08llx (0x%02llx) ",
3349 seqno[offset], offset * 8);
3350 }
3351 seq_putc(m, '\n');
3352
3353 seq_puts(m, " Last wait: ");
3354 for (j = 0; j < num_rings; j++) {
Dave Gordonc3232b12016-03-23 18:19:53 +00003355 offset = id + (j * I915_NUM_ENGINES);
Ben Widawskye04934c2014-06-30 09:53:42 -07003356 seq_printf(m, "0x%08llx (0x%02llx) ",
3357 seqno[offset], offset * 8);
3358 }
3359 seq_putc(m, '\n');
3360
3361 }
3362 kunmap_atomic(seqno);
3363 } else {
3364 seq_puts(m, " Last signal:");
Akash Goel3b3f1652016-10-13 22:44:48 +05303365 for_each_engine(engine, dev_priv, id)
Ben Widawskye04934c2014-06-30 09:53:42 -07003366 for (j = 0; j < num_rings; j++)
3367 seq_printf(m, "0x%08x\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003368 I915_READ(engine->semaphore.mbox.signal[j]));
Ben Widawskye04934c2014-06-30 09:53:42 -07003369 seq_putc(m, '\n');
3370 }
3371
Paulo Zanoni03872062014-07-09 14:31:57 -03003372 intel_runtime_pm_put(dev_priv);
Ben Widawskye04934c2014-06-30 09:53:42 -07003373 mutex_unlock(&dev->struct_mutex);
3374 return 0;
3375}
3376
Daniel Vetter728e29d2014-06-25 22:01:53 +03003377static int i915_shared_dplls_info(struct seq_file *m, void *unused)
3378{
David Weinehall36cdd012016-08-22 13:59:31 +03003379 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3380 struct drm_device *dev = &dev_priv->drm;
Daniel Vetter728e29d2014-06-25 22:01:53 +03003381 int i;
3382
3383 drm_modeset_lock_all(dev);
3384 for (i = 0; i < dev_priv->num_shared_dpll; i++) {
3385 struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i];
3386
3387 seq_printf(m, "DPLL%i: %s, id: %i\n", i, pll->name, pll->id);
Maarten Lankhorst2dd66ebd2016-03-14 09:27:52 +01003388 seq_printf(m, " crtc_mask: 0x%08x, active: 0x%x, on: %s\n",
Ander Conselvan de Oliveira2c42e532016-12-29 17:22:09 +02003389 pll->state.crtc_mask, pll->active_mask, yesno(pll->on));
Daniel Vetter728e29d2014-06-25 22:01:53 +03003390 seq_printf(m, " tracked hardware state:\n");
Ander Conselvan de Oliveira2c42e532016-12-29 17:22:09 +02003391 seq_printf(m, " dpll: 0x%08x\n", pll->state.hw_state.dpll);
Ander Conselvan de Oliveira3e369b72014-10-29 11:32:32 +02003392 seq_printf(m, " dpll_md: 0x%08x\n",
Ander Conselvan de Oliveira2c42e532016-12-29 17:22:09 +02003393 pll->state.hw_state.dpll_md);
3394 seq_printf(m, " fp0: 0x%08x\n", pll->state.hw_state.fp0);
3395 seq_printf(m, " fp1: 0x%08x\n", pll->state.hw_state.fp1);
3396 seq_printf(m, " wrpll: 0x%08x\n", pll->state.hw_state.wrpll);
Daniel Vetter728e29d2014-06-25 22:01:53 +03003397 }
3398 drm_modeset_unlock_all(dev);
3399
3400 return 0;
3401}
3402
Damien Lespiau1ed1ef92014-08-30 16:50:59 +01003403static int i915_wa_registers(struct seq_file *m, void *unused)
Arun Siluvery888b5992014-08-26 14:44:51 +01003404{
3405 int i;
3406 int ret;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003407 struct intel_engine_cs *engine;
David Weinehall36cdd012016-08-22 13:59:31 +03003408 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3409 struct drm_device *dev = &dev_priv->drm;
Arun Siluvery33136b02016-01-21 21:43:47 +00003410 struct i915_workarounds *workarounds = &dev_priv->workarounds;
Dave Gordonc3232b12016-03-23 18:19:53 +00003411 enum intel_engine_id id;
Arun Siluvery888b5992014-08-26 14:44:51 +01003412
Arun Siluvery888b5992014-08-26 14:44:51 +01003413 ret = mutex_lock_interruptible(&dev->struct_mutex);
3414 if (ret)
3415 return ret;
3416
3417 intel_runtime_pm_get(dev_priv);
3418
Arun Siluvery33136b02016-01-21 21:43:47 +00003419 seq_printf(m, "Workarounds applied: %d\n", workarounds->count);
Akash Goel3b3f1652016-10-13 22:44:48 +05303420 for_each_engine(engine, dev_priv, id)
Arun Siluvery33136b02016-01-21 21:43:47 +00003421 seq_printf(m, "HW whitelist count for %s: %d\n",
Dave Gordonc3232b12016-03-23 18:19:53 +00003422 engine->name, workarounds->hw_whitelist_count[id]);
Arun Siluvery33136b02016-01-21 21:43:47 +00003423 for (i = 0; i < workarounds->count; ++i) {
Ville Syrjäläf0f59a02015-11-18 15:33:26 +02003424 i915_reg_t addr;
3425 u32 mask, value, read;
Mika Kuoppala2fa60f62014-10-07 17:21:27 +03003426 bool ok;
Arun Siluvery888b5992014-08-26 14:44:51 +01003427
Arun Siluvery33136b02016-01-21 21:43:47 +00003428 addr = workarounds->reg[i].addr;
3429 mask = workarounds->reg[i].mask;
3430 value = workarounds->reg[i].value;
Mika Kuoppala2fa60f62014-10-07 17:21:27 +03003431 read = I915_READ(addr);
3432 ok = (value & mask) == (read & mask);
3433 seq_printf(m, "0x%X: 0x%08X, mask: 0x%08X, read: 0x%08x, status: %s\n",
Ville Syrjäläf0f59a02015-11-18 15:33:26 +02003434 i915_mmio_reg_offset(addr), value, mask, read, ok ? "OK" : "FAIL");
Arun Siluvery888b5992014-08-26 14:44:51 +01003435 }
3436
3437 intel_runtime_pm_put(dev_priv);
3438 mutex_unlock(&dev->struct_mutex);
3439
3440 return 0;
3441}
3442
Kumar, Maheshd2d4f392017-08-17 19:15:29 +05303443static int i915_ipc_status_show(struct seq_file *m, void *data)
3444{
3445 struct drm_i915_private *dev_priv = m->private;
3446
3447 seq_printf(m, "Isochronous Priority Control: %s\n",
3448 yesno(dev_priv->ipc_enabled));
3449 return 0;
3450}
3451
3452static int i915_ipc_status_open(struct inode *inode, struct file *file)
3453{
3454 struct drm_i915_private *dev_priv = inode->i_private;
3455
3456 if (!HAS_IPC(dev_priv))
3457 return -ENODEV;
3458
3459 return single_open(file, i915_ipc_status_show, dev_priv);
3460}
3461
3462static ssize_t i915_ipc_status_write(struct file *file, const char __user *ubuf,
3463 size_t len, loff_t *offp)
3464{
3465 struct seq_file *m = file->private_data;
3466 struct drm_i915_private *dev_priv = m->private;
3467 int ret;
3468 bool enable;
3469
3470 ret = kstrtobool_from_user(ubuf, len, &enable);
3471 if (ret < 0)
3472 return ret;
3473
3474 intel_runtime_pm_get(dev_priv);
3475 if (!dev_priv->ipc_enabled && enable)
3476 DRM_INFO("Enabling IPC: WM will be proper only after next commit\n");
3477 dev_priv->wm.distrust_bios_wm = true;
3478 dev_priv->ipc_enabled = enable;
3479 intel_enable_ipc(dev_priv);
3480 intel_runtime_pm_put(dev_priv);
3481
3482 return len;
3483}
3484
3485static const struct file_operations i915_ipc_status_fops = {
3486 .owner = THIS_MODULE,
3487 .open = i915_ipc_status_open,
3488 .read = seq_read,
3489 .llseek = seq_lseek,
3490 .release = single_release,
3491 .write = i915_ipc_status_write
3492};
3493
Damien Lespiauc5511e42014-11-04 17:06:51 +00003494static int i915_ddb_info(struct seq_file *m, void *unused)
3495{
David Weinehall36cdd012016-08-22 13:59:31 +03003496 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3497 struct drm_device *dev = &dev_priv->drm;
Damien Lespiauc5511e42014-11-04 17:06:51 +00003498 struct skl_ddb_allocation *ddb;
3499 struct skl_ddb_entry *entry;
3500 enum pipe pipe;
3501 int plane;
3502
David Weinehall36cdd012016-08-22 13:59:31 +03003503 if (INTEL_GEN(dev_priv) < 9)
Damien Lespiau2fcffe12014-12-03 17:33:24 +00003504 return 0;
3505
Damien Lespiauc5511e42014-11-04 17:06:51 +00003506 drm_modeset_lock_all(dev);
3507
3508 ddb = &dev_priv->wm.skl_hw.ddb;
3509
3510 seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size");
3511
3512 for_each_pipe(dev_priv, pipe) {
3513 seq_printf(m, "Pipe %c\n", pipe_name(pipe));
3514
Matt Roper8b364b42016-10-26 15:51:28 -07003515 for_each_universal_plane(dev_priv, pipe, plane) {
Damien Lespiauc5511e42014-11-04 17:06:51 +00003516 entry = &ddb->plane[pipe][plane];
3517 seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1,
3518 entry->start, entry->end,
3519 skl_ddb_entry_size(entry));
3520 }
3521
Matt Roper4969d332015-09-24 15:53:10 -07003522 entry = &ddb->plane[pipe][PLANE_CURSOR];
Damien Lespiauc5511e42014-11-04 17:06:51 +00003523 seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start,
3524 entry->end, skl_ddb_entry_size(entry));
3525 }
3526
3527 drm_modeset_unlock_all(dev);
3528
3529 return 0;
3530}
3531
Vandana Kannana54746e2015-03-03 20:53:10 +05303532static void drrs_status_per_crtc(struct seq_file *m,
David Weinehall36cdd012016-08-22 13:59:31 +03003533 struct drm_device *dev,
3534 struct intel_crtc *intel_crtc)
Vandana Kannana54746e2015-03-03 20:53:10 +05303535{
Chris Wilsonfac5e232016-07-04 11:34:36 +01003536 struct drm_i915_private *dev_priv = to_i915(dev);
Vandana Kannana54746e2015-03-03 20:53:10 +05303537 struct i915_drrs *drrs = &dev_priv->drrs;
3538 int vrefresh = 0;
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003539 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003540 struct drm_connector_list_iter conn_iter;
Vandana Kannana54746e2015-03-03 20:53:10 +05303541
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003542 drm_connector_list_iter_begin(dev, &conn_iter);
3543 drm_for_each_connector_iter(connector, &conn_iter) {
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003544 if (connector->state->crtc != &intel_crtc->base)
3545 continue;
3546
3547 seq_printf(m, "%s:\n", connector->name);
Vandana Kannana54746e2015-03-03 20:53:10 +05303548 }
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003549 drm_connector_list_iter_end(&conn_iter);
Vandana Kannana54746e2015-03-03 20:53:10 +05303550
3551 if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT)
3552 seq_puts(m, "\tVBT: DRRS_type: Static");
3553 else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT)
3554 seq_puts(m, "\tVBT: DRRS_type: Seamless");
3555 else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED)
3556 seq_puts(m, "\tVBT: DRRS_type: None");
3557 else
3558 seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value");
3559
3560 seq_puts(m, "\n\n");
3561
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003562 if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) {
Vandana Kannana54746e2015-03-03 20:53:10 +05303563 struct intel_panel *panel;
3564
3565 mutex_lock(&drrs->mutex);
3566 /* DRRS Supported */
3567 seq_puts(m, "\tDRRS Supported: Yes\n");
3568
3569 /* disable_drrs() will make drrs->dp NULL */
3570 if (!drrs->dp) {
3571 seq_puts(m, "Idleness DRRS: Disabled");
3572 mutex_unlock(&drrs->mutex);
3573 return;
3574 }
3575
3576 panel = &drrs->dp->attached_connector->panel;
3577 seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X",
3578 drrs->busy_frontbuffer_bits);
3579
3580 seq_puts(m, "\n\t\t");
3581 if (drrs->refresh_rate_type == DRRS_HIGH_RR) {
3582 seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n");
3583 vrefresh = panel->fixed_mode->vrefresh;
3584 } else if (drrs->refresh_rate_type == DRRS_LOW_RR) {
3585 seq_puts(m, "DRRS_State: DRRS_LOW_RR\n");
3586 vrefresh = panel->downclock_mode->vrefresh;
3587 } else {
3588 seq_printf(m, "DRRS_State: Unknown(%d)\n",
3589 drrs->refresh_rate_type);
3590 mutex_unlock(&drrs->mutex);
3591 return;
3592 }
3593 seq_printf(m, "\t\tVrefresh: %d", vrefresh);
3594
3595 seq_puts(m, "\n\t\t");
3596 mutex_unlock(&drrs->mutex);
3597 } else {
3598 /* DRRS not supported. Print the VBT parameter*/
3599 seq_puts(m, "\tDRRS Supported : No");
3600 }
3601 seq_puts(m, "\n");
3602}
3603
3604static int i915_drrs_status(struct seq_file *m, void *unused)
3605{
David Weinehall36cdd012016-08-22 13:59:31 +03003606 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3607 struct drm_device *dev = &dev_priv->drm;
Vandana Kannana54746e2015-03-03 20:53:10 +05303608 struct intel_crtc *intel_crtc;
3609 int active_crtc_cnt = 0;
3610
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003611 drm_modeset_lock_all(dev);
Vandana Kannana54746e2015-03-03 20:53:10 +05303612 for_each_intel_crtc(dev, intel_crtc) {
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003613 if (intel_crtc->base.state->active) {
Vandana Kannana54746e2015-03-03 20:53:10 +05303614 active_crtc_cnt++;
3615 seq_printf(m, "\nCRTC %d: ", active_crtc_cnt);
3616
3617 drrs_status_per_crtc(m, dev, intel_crtc);
3618 }
Vandana Kannana54746e2015-03-03 20:53:10 +05303619 }
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003620 drm_modeset_unlock_all(dev);
Vandana Kannana54746e2015-03-03 20:53:10 +05303621
3622 if (!active_crtc_cnt)
3623 seq_puts(m, "No active crtc found\n");
3624
3625 return 0;
3626}
3627
Dave Airlie11bed952014-05-12 15:22:27 +10003628static int i915_dp_mst_info(struct seq_file *m, void *unused)
3629{
David Weinehall36cdd012016-08-22 13:59:31 +03003630 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3631 struct drm_device *dev = &dev_priv->drm;
Dave Airlie11bed952014-05-12 15:22:27 +10003632 struct intel_encoder *intel_encoder;
3633 struct intel_digital_port *intel_dig_port;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003634 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003635 struct drm_connector_list_iter conn_iter;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003636
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003637 drm_connector_list_iter_begin(dev, &conn_iter);
3638 drm_for_each_connector_iter(connector, &conn_iter) {
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003639 if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort)
Dave Airlie11bed952014-05-12 15:22:27 +10003640 continue;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003641
3642 intel_encoder = intel_attached_encoder(connector);
3643 if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST)
3644 continue;
3645
3646 intel_dig_port = enc_to_dig_port(&intel_encoder->base);
Dave Airlie11bed952014-05-12 15:22:27 +10003647 if (!intel_dig_port->dp.can_mst)
3648 continue;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003649
Jim Bride40ae80c2016-04-14 10:18:37 -07003650 seq_printf(m, "MST Source Port %c\n",
3651 port_name(intel_dig_port->port));
Dave Airlie11bed952014-05-12 15:22:27 +10003652 drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr);
3653 }
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003654 drm_connector_list_iter_end(&conn_iter);
3655
Dave Airlie11bed952014-05-12 15:22:27 +10003656 return 0;
3657}
3658
Todd Previteeb3394fa2015-04-18 00:04:19 -07003659static ssize_t i915_displayport_test_active_write(struct file *file,
David Weinehall36cdd012016-08-22 13:59:31 +03003660 const char __user *ubuf,
3661 size_t len, loff_t *offp)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003662{
3663 char *input_buffer;
3664 int status = 0;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003665 struct drm_device *dev;
3666 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003667 struct drm_connector_list_iter conn_iter;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003668 struct intel_dp *intel_dp;
3669 int val = 0;
3670
Sudip Mukherjee9aaffa32015-07-21 17:36:45 +05303671 dev = ((struct seq_file *)file->private_data)->private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003672
Todd Previteeb3394fa2015-04-18 00:04:19 -07003673 if (len == 0)
3674 return 0;
3675
Geliang Tang261aeba2017-05-06 23:40:17 +08003676 input_buffer = memdup_user_nul(ubuf, len);
3677 if (IS_ERR(input_buffer))
3678 return PTR_ERR(input_buffer);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003679
Todd Previteeb3394fa2015-04-18 00:04:19 -07003680 DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len);
3681
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003682 drm_connector_list_iter_begin(dev, &conn_iter);
3683 drm_for_each_connector_iter(connector, &conn_iter) {
Maarten Lankhorsta874b6a2017-06-26 10:18:35 +02003684 struct intel_encoder *encoder;
3685
Todd Previteeb3394fa2015-04-18 00:04:19 -07003686 if (connector->connector_type !=
3687 DRM_MODE_CONNECTOR_DisplayPort)
3688 continue;
3689
Maarten Lankhorsta874b6a2017-06-26 10:18:35 +02003690 encoder = to_intel_encoder(connector->encoder);
3691 if (encoder && encoder->type == INTEL_OUTPUT_DP_MST)
3692 continue;
3693
3694 if (encoder && connector->status == connector_status_connected) {
3695 intel_dp = enc_to_intel_dp(&encoder->base);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003696 status = kstrtoint(input_buffer, 10, &val);
3697 if (status < 0)
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003698 break;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003699 DRM_DEBUG_DRIVER("Got %d for test active\n", val);
3700 /* To prevent erroneous activation of the compliance
3701 * testing code, only accept an actual value of 1 here
3702 */
3703 if (val == 1)
Manasi Navarec1617ab2016-12-09 16:22:50 -08003704 intel_dp->compliance.test_active = 1;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003705 else
Manasi Navarec1617ab2016-12-09 16:22:50 -08003706 intel_dp->compliance.test_active = 0;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003707 }
3708 }
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003709 drm_connector_list_iter_end(&conn_iter);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003710 kfree(input_buffer);
3711 if (status < 0)
3712 return status;
3713
3714 *offp += len;
3715 return len;
3716}
3717
3718static int i915_displayport_test_active_show(struct seq_file *m, void *data)
3719{
3720 struct drm_device *dev = m->private;
3721 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003722 struct drm_connector_list_iter conn_iter;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003723 struct intel_dp *intel_dp;
3724
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003725 drm_connector_list_iter_begin(dev, &conn_iter);
3726 drm_for_each_connector_iter(connector, &conn_iter) {
Maarten Lankhorsta874b6a2017-06-26 10:18:35 +02003727 struct intel_encoder *encoder;
3728
Todd Previteeb3394fa2015-04-18 00:04:19 -07003729 if (connector->connector_type !=
3730 DRM_MODE_CONNECTOR_DisplayPort)
3731 continue;
3732
Maarten Lankhorsta874b6a2017-06-26 10:18:35 +02003733 encoder = to_intel_encoder(connector->encoder);
3734 if (encoder && encoder->type == INTEL_OUTPUT_DP_MST)
3735 continue;
3736
3737 if (encoder && connector->status == connector_status_connected) {
3738 intel_dp = enc_to_intel_dp(&encoder->base);
Manasi Navarec1617ab2016-12-09 16:22:50 -08003739 if (intel_dp->compliance.test_active)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003740 seq_puts(m, "1");
3741 else
3742 seq_puts(m, "0");
3743 } else
3744 seq_puts(m, "0");
3745 }
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003746 drm_connector_list_iter_end(&conn_iter);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003747
3748 return 0;
3749}
3750
3751static int i915_displayport_test_active_open(struct inode *inode,
David Weinehall36cdd012016-08-22 13:59:31 +03003752 struct file *file)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003753{
David Weinehall36cdd012016-08-22 13:59:31 +03003754 struct drm_i915_private *dev_priv = inode->i_private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003755
David Weinehall36cdd012016-08-22 13:59:31 +03003756 return single_open(file, i915_displayport_test_active_show,
3757 &dev_priv->drm);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003758}
3759
3760static const struct file_operations i915_displayport_test_active_fops = {
3761 .owner = THIS_MODULE,
3762 .open = i915_displayport_test_active_open,
3763 .read = seq_read,
3764 .llseek = seq_lseek,
3765 .release = single_release,
3766 .write = i915_displayport_test_active_write
3767};
3768
3769static int i915_displayport_test_data_show(struct seq_file *m, void *data)
3770{
3771 struct drm_device *dev = m->private;
3772 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003773 struct drm_connector_list_iter conn_iter;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003774 struct intel_dp *intel_dp;
3775
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003776 drm_connector_list_iter_begin(dev, &conn_iter);
3777 drm_for_each_connector_iter(connector, &conn_iter) {
Maarten Lankhorsta874b6a2017-06-26 10:18:35 +02003778 struct intel_encoder *encoder;
3779
Todd Previteeb3394fa2015-04-18 00:04:19 -07003780 if (connector->connector_type !=
3781 DRM_MODE_CONNECTOR_DisplayPort)
3782 continue;
3783
Maarten Lankhorsta874b6a2017-06-26 10:18:35 +02003784 encoder = to_intel_encoder(connector->encoder);
3785 if (encoder && encoder->type == INTEL_OUTPUT_DP_MST)
3786 continue;
3787
3788 if (encoder && connector->status == connector_status_connected) {
3789 intel_dp = enc_to_intel_dp(&encoder->base);
Manasi Navareb48a5ba2017-01-20 19:09:28 -08003790 if (intel_dp->compliance.test_type ==
3791 DP_TEST_LINK_EDID_READ)
3792 seq_printf(m, "%lx",
3793 intel_dp->compliance.test_data.edid);
Manasi Navare611032b2017-01-24 08:21:49 -08003794 else if (intel_dp->compliance.test_type ==
3795 DP_TEST_LINK_VIDEO_PATTERN) {
3796 seq_printf(m, "hdisplay: %d\n",
3797 intel_dp->compliance.test_data.hdisplay);
3798 seq_printf(m, "vdisplay: %d\n",
3799 intel_dp->compliance.test_data.vdisplay);
3800 seq_printf(m, "bpc: %u\n",
3801 intel_dp->compliance.test_data.bpc);
3802 }
Todd Previteeb3394fa2015-04-18 00:04:19 -07003803 } else
3804 seq_puts(m, "0");
3805 }
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003806 drm_connector_list_iter_end(&conn_iter);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003807
3808 return 0;
3809}
3810static int i915_displayport_test_data_open(struct inode *inode,
David Weinehall36cdd012016-08-22 13:59:31 +03003811 struct file *file)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003812{
David Weinehall36cdd012016-08-22 13:59:31 +03003813 struct drm_i915_private *dev_priv = inode->i_private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003814
David Weinehall36cdd012016-08-22 13:59:31 +03003815 return single_open(file, i915_displayport_test_data_show,
3816 &dev_priv->drm);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003817}
3818
3819static const struct file_operations i915_displayport_test_data_fops = {
3820 .owner = THIS_MODULE,
3821 .open = i915_displayport_test_data_open,
3822 .read = seq_read,
3823 .llseek = seq_lseek,
3824 .release = single_release
3825};
3826
3827static int i915_displayport_test_type_show(struct seq_file *m, void *data)
3828{
3829 struct drm_device *dev = m->private;
3830 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003831 struct drm_connector_list_iter conn_iter;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003832 struct intel_dp *intel_dp;
3833
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003834 drm_connector_list_iter_begin(dev, &conn_iter);
3835 drm_for_each_connector_iter(connector, &conn_iter) {
Maarten Lankhorsta874b6a2017-06-26 10:18:35 +02003836 struct intel_encoder *encoder;
3837
Todd Previteeb3394fa2015-04-18 00:04:19 -07003838 if (connector->connector_type !=
3839 DRM_MODE_CONNECTOR_DisplayPort)
3840 continue;
3841
Maarten Lankhorsta874b6a2017-06-26 10:18:35 +02003842 encoder = to_intel_encoder(connector->encoder);
3843 if (encoder && encoder->type == INTEL_OUTPUT_DP_MST)
3844 continue;
3845
3846 if (encoder && connector->status == connector_status_connected) {
3847 intel_dp = enc_to_intel_dp(&encoder->base);
Manasi Navarec1617ab2016-12-09 16:22:50 -08003848 seq_printf(m, "%02lx", intel_dp->compliance.test_type);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003849 } else
3850 seq_puts(m, "0");
3851 }
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003852 drm_connector_list_iter_end(&conn_iter);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003853
3854 return 0;
3855}
3856
3857static int i915_displayport_test_type_open(struct inode *inode,
3858 struct file *file)
3859{
David Weinehall36cdd012016-08-22 13:59:31 +03003860 struct drm_i915_private *dev_priv = inode->i_private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003861
David Weinehall36cdd012016-08-22 13:59:31 +03003862 return single_open(file, i915_displayport_test_type_show,
3863 &dev_priv->drm);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003864}
3865
3866static const struct file_operations i915_displayport_test_type_fops = {
3867 .owner = THIS_MODULE,
3868 .open = i915_displayport_test_type_open,
3869 .read = seq_read,
3870 .llseek = seq_lseek,
3871 .release = single_release
3872};
3873
Damien Lespiau97e94b22014-11-04 17:06:50 +00003874static void wm_latency_show(struct seq_file *m, const uint16_t wm[8])
Ville Syrjälä369a1342014-01-22 14:36:08 +02003875{
David Weinehall36cdd012016-08-22 13:59:31 +03003876 struct drm_i915_private *dev_priv = m->private;
3877 struct drm_device *dev = &dev_priv->drm;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003878 int level;
Ville Syrjäläde38b952015-06-24 22:00:09 +03003879 int num_levels;
3880
David Weinehall36cdd012016-08-22 13:59:31 +03003881 if (IS_CHERRYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03003882 num_levels = 3;
David Weinehall36cdd012016-08-22 13:59:31 +03003883 else if (IS_VALLEYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03003884 num_levels = 1;
Ville Syrjälä04548cb2017-04-21 21:14:29 +03003885 else if (IS_G4X(dev_priv))
3886 num_levels = 3;
Ville Syrjäläde38b952015-06-24 22:00:09 +03003887 else
Tvrtko Ursulin5db94012016-10-13 11:03:10 +01003888 num_levels = ilk_wm_max_level(dev_priv) + 1;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003889
3890 drm_modeset_lock_all(dev);
3891
3892 for (level = 0; level < num_levels; level++) {
3893 unsigned int latency = wm[level];
3894
Damien Lespiau97e94b22014-11-04 17:06:50 +00003895 /*
3896 * - WM1+ latency values in 0.5us units
Ville Syrjäläde38b952015-06-24 22:00:09 +03003897 * - latencies are in us on gen9/vlv/chv
Damien Lespiau97e94b22014-11-04 17:06:50 +00003898 */
Ville Syrjälä04548cb2017-04-21 21:14:29 +03003899 if (INTEL_GEN(dev_priv) >= 9 ||
3900 IS_VALLEYVIEW(dev_priv) ||
3901 IS_CHERRYVIEW(dev_priv) ||
3902 IS_G4X(dev_priv))
Damien Lespiau97e94b22014-11-04 17:06:50 +00003903 latency *= 10;
3904 else if (level > 0)
Ville Syrjälä369a1342014-01-22 14:36:08 +02003905 latency *= 5;
3906
3907 seq_printf(m, "WM%d %u (%u.%u usec)\n",
Damien Lespiau97e94b22014-11-04 17:06:50 +00003908 level, wm[level], latency / 10, latency % 10);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003909 }
3910
3911 drm_modeset_unlock_all(dev);
3912}
3913
3914static int pri_wm_latency_show(struct seq_file *m, void *data)
3915{
David Weinehall36cdd012016-08-22 13:59:31 +03003916 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003917 const uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003918
David Weinehall36cdd012016-08-22 13:59:31 +03003919 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00003920 latencies = dev_priv->wm.skl_latency;
3921 else
David Weinehall36cdd012016-08-22 13:59:31 +03003922 latencies = dev_priv->wm.pri_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003923
3924 wm_latency_show(m, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003925
3926 return 0;
3927}
3928
3929static int spr_wm_latency_show(struct seq_file *m, void *data)
3930{
David Weinehall36cdd012016-08-22 13:59:31 +03003931 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003932 const uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003933
David Weinehall36cdd012016-08-22 13:59:31 +03003934 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00003935 latencies = dev_priv->wm.skl_latency;
3936 else
David Weinehall36cdd012016-08-22 13:59:31 +03003937 latencies = dev_priv->wm.spr_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003938
3939 wm_latency_show(m, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003940
3941 return 0;
3942}
3943
3944static int cur_wm_latency_show(struct seq_file *m, void *data)
3945{
David Weinehall36cdd012016-08-22 13:59:31 +03003946 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003947 const uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003948
David Weinehall36cdd012016-08-22 13:59:31 +03003949 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00003950 latencies = dev_priv->wm.skl_latency;
3951 else
David Weinehall36cdd012016-08-22 13:59:31 +03003952 latencies = dev_priv->wm.cur_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003953
3954 wm_latency_show(m, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003955
3956 return 0;
3957}
3958
3959static int pri_wm_latency_open(struct inode *inode, struct file *file)
3960{
David Weinehall36cdd012016-08-22 13:59:31 +03003961 struct drm_i915_private *dev_priv = inode->i_private;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003962
Ville Syrjälä04548cb2017-04-21 21:14:29 +03003963 if (INTEL_GEN(dev_priv) < 5 && !IS_G4X(dev_priv))
Ville Syrjälä369a1342014-01-22 14:36:08 +02003964 return -ENODEV;
3965
David Weinehall36cdd012016-08-22 13:59:31 +03003966 return single_open(file, pri_wm_latency_show, dev_priv);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003967}
3968
3969static int spr_wm_latency_open(struct inode *inode, struct file *file)
3970{
David Weinehall36cdd012016-08-22 13:59:31 +03003971 struct drm_i915_private *dev_priv = inode->i_private;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003972
David Weinehall36cdd012016-08-22 13:59:31 +03003973 if (HAS_GMCH_DISPLAY(dev_priv))
Ville Syrjälä369a1342014-01-22 14:36:08 +02003974 return -ENODEV;
3975
David Weinehall36cdd012016-08-22 13:59:31 +03003976 return single_open(file, spr_wm_latency_show, dev_priv);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003977}
3978
3979static int cur_wm_latency_open(struct inode *inode, struct file *file)
3980{
David Weinehall36cdd012016-08-22 13:59:31 +03003981 struct drm_i915_private *dev_priv = inode->i_private;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003982
David Weinehall36cdd012016-08-22 13:59:31 +03003983 if (HAS_GMCH_DISPLAY(dev_priv))
Ville Syrjälä369a1342014-01-22 14:36:08 +02003984 return -ENODEV;
3985
David Weinehall36cdd012016-08-22 13:59:31 +03003986 return single_open(file, cur_wm_latency_show, dev_priv);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003987}
3988
3989static ssize_t wm_latency_write(struct file *file, const char __user *ubuf,
Damien Lespiau97e94b22014-11-04 17:06:50 +00003990 size_t len, loff_t *offp, uint16_t wm[8])
Ville Syrjälä369a1342014-01-22 14:36:08 +02003991{
3992 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03003993 struct drm_i915_private *dev_priv = m->private;
3994 struct drm_device *dev = &dev_priv->drm;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003995 uint16_t new[8] = { 0 };
Ville Syrjäläde38b952015-06-24 22:00:09 +03003996 int num_levels;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003997 int level;
3998 int ret;
3999 char tmp[32];
4000
David Weinehall36cdd012016-08-22 13:59:31 +03004001 if (IS_CHERRYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03004002 num_levels = 3;
David Weinehall36cdd012016-08-22 13:59:31 +03004003 else if (IS_VALLEYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03004004 num_levels = 1;
Ville Syrjälä04548cb2017-04-21 21:14:29 +03004005 else if (IS_G4X(dev_priv))
4006 num_levels = 3;
Ville Syrjäläde38b952015-06-24 22:00:09 +03004007 else
Tvrtko Ursulin5db94012016-10-13 11:03:10 +01004008 num_levels = ilk_wm_max_level(dev_priv) + 1;
Ville Syrjäläde38b952015-06-24 22:00:09 +03004009
Ville Syrjälä369a1342014-01-22 14:36:08 +02004010 if (len >= sizeof(tmp))
4011 return -EINVAL;
4012
4013 if (copy_from_user(tmp, ubuf, len))
4014 return -EFAULT;
4015
4016 tmp[len] = '\0';
4017
Damien Lespiau97e94b22014-11-04 17:06:50 +00004018 ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu",
4019 &new[0], &new[1], &new[2], &new[3],
4020 &new[4], &new[5], &new[6], &new[7]);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004021 if (ret != num_levels)
4022 return -EINVAL;
4023
4024 drm_modeset_lock_all(dev);
4025
4026 for (level = 0; level < num_levels; level++)
4027 wm[level] = new[level];
4028
4029 drm_modeset_unlock_all(dev);
4030
4031 return len;
4032}
4033
4034
4035static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf,
4036 size_t len, loff_t *offp)
4037{
4038 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03004039 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004040 uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004041
David Weinehall36cdd012016-08-22 13:59:31 +03004042 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00004043 latencies = dev_priv->wm.skl_latency;
4044 else
David Weinehall36cdd012016-08-22 13:59:31 +03004045 latencies = dev_priv->wm.pri_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004046
4047 return wm_latency_write(file, ubuf, len, offp, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004048}
4049
4050static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf,
4051 size_t len, loff_t *offp)
4052{
4053 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03004054 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004055 uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004056
David Weinehall36cdd012016-08-22 13:59:31 +03004057 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00004058 latencies = dev_priv->wm.skl_latency;
4059 else
David Weinehall36cdd012016-08-22 13:59:31 +03004060 latencies = dev_priv->wm.spr_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004061
4062 return wm_latency_write(file, ubuf, len, offp, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004063}
4064
4065static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf,
4066 size_t len, loff_t *offp)
4067{
4068 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03004069 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004070 uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004071
David Weinehall36cdd012016-08-22 13:59:31 +03004072 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00004073 latencies = dev_priv->wm.skl_latency;
4074 else
David Weinehall36cdd012016-08-22 13:59:31 +03004075 latencies = dev_priv->wm.cur_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004076
4077 return wm_latency_write(file, ubuf, len, offp, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004078}
4079
4080static const struct file_operations i915_pri_wm_latency_fops = {
4081 .owner = THIS_MODULE,
4082 .open = pri_wm_latency_open,
4083 .read = seq_read,
4084 .llseek = seq_lseek,
4085 .release = single_release,
4086 .write = pri_wm_latency_write
4087};
4088
4089static const struct file_operations i915_spr_wm_latency_fops = {
4090 .owner = THIS_MODULE,
4091 .open = spr_wm_latency_open,
4092 .read = seq_read,
4093 .llseek = seq_lseek,
4094 .release = single_release,
4095 .write = spr_wm_latency_write
4096};
4097
4098static const struct file_operations i915_cur_wm_latency_fops = {
4099 .owner = THIS_MODULE,
4100 .open = cur_wm_latency_open,
4101 .read = seq_read,
4102 .llseek = seq_lseek,
4103 .release = single_release,
4104 .write = cur_wm_latency_write
4105};
4106
Kees Cook647416f2013-03-10 14:10:06 -07004107static int
4108i915_wedged_get(void *data, u64 *val)
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004109{
David Weinehall36cdd012016-08-22 13:59:31 +03004110 struct drm_i915_private *dev_priv = data;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004111
Chris Wilsond98c52c2016-04-13 17:35:05 +01004112 *val = i915_terminally_wedged(&dev_priv->gpu_error);
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004113
Kees Cook647416f2013-03-10 14:10:06 -07004114 return 0;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004115}
4116
Kees Cook647416f2013-03-10 14:10:06 -07004117static int
4118i915_wedged_set(void *data, u64 val)
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004119{
Chris Wilson598b6b52017-03-25 13:47:35 +00004120 struct drm_i915_private *i915 = data;
4121 struct intel_engine_cs *engine;
4122 unsigned int tmp;
Imre Deakd46c0512014-04-14 20:24:27 +03004123
Mika Kuoppalab8d24a02015-01-28 17:03:14 +02004124 /*
4125 * There is no safeguard against this debugfs entry colliding
4126 * with the hangcheck calling same i915_handle_error() in
4127 * parallel, causing an explosion. For now we assume that the
4128 * test harness is responsible enough not to inject gpu hangs
4129 * while it is writing to 'i915_wedged'
4130 */
4131
Chris Wilson598b6b52017-03-25 13:47:35 +00004132 if (i915_reset_backoff(&i915->gpu_error))
Mika Kuoppalab8d24a02015-01-28 17:03:14 +02004133 return -EAGAIN;
4134
Chris Wilson598b6b52017-03-25 13:47:35 +00004135 for_each_engine_masked(engine, i915, val, tmp) {
4136 engine->hangcheck.seqno = intel_engine_get_seqno(engine);
4137 engine->hangcheck.stalled = true;
4138 }
Imre Deakd46c0512014-04-14 20:24:27 +03004139
Chris Wilson598b6b52017-03-25 13:47:35 +00004140 i915_handle_error(i915, val, "Manually setting wedged to %llu", val);
4141
4142 wait_on_bit(&i915->gpu_error.flags,
Chris Wilsond3df42b2017-03-16 17:13:05 +00004143 I915_RESET_HANDOFF,
4144 TASK_UNINTERRUPTIBLE);
4145
Kees Cook647416f2013-03-10 14:10:06 -07004146 return 0;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004147}
4148
Kees Cook647416f2013-03-10 14:10:06 -07004149DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops,
4150 i915_wedged_get, i915_wedged_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03004151 "%llu\n");
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004152
Kees Cook647416f2013-03-10 14:10:06 -07004153static int
Chris Wilson64486ae2017-03-07 15:59:08 +00004154fault_irq_set(struct drm_i915_private *i915,
4155 unsigned long *irq,
4156 unsigned long val)
4157{
4158 int err;
4159
4160 err = mutex_lock_interruptible(&i915->drm.struct_mutex);
4161 if (err)
4162 return err;
4163
4164 err = i915_gem_wait_for_idle(i915,
4165 I915_WAIT_LOCKED |
4166 I915_WAIT_INTERRUPTIBLE);
4167 if (err)
4168 goto err_unlock;
4169
Chris Wilson64486ae2017-03-07 15:59:08 +00004170 *irq = val;
4171 mutex_unlock(&i915->drm.struct_mutex);
4172
4173 /* Flush idle worker to disarm irq */
Chris Wilson7c262402017-10-06 11:40:38 +01004174 drain_delayed_work(&i915->gt.idle_work);
Chris Wilson64486ae2017-03-07 15:59:08 +00004175
4176 return 0;
4177
4178err_unlock:
4179 mutex_unlock(&i915->drm.struct_mutex);
4180 return err;
4181}
4182
4183static int
Chris Wilson094f9a52013-09-25 17:34:55 +01004184i915_ring_missed_irq_get(void *data, u64 *val)
4185{
David Weinehall36cdd012016-08-22 13:59:31 +03004186 struct drm_i915_private *dev_priv = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004187
4188 *val = dev_priv->gpu_error.missed_irq_rings;
4189 return 0;
4190}
4191
4192static int
4193i915_ring_missed_irq_set(void *data, u64 val)
4194{
Chris Wilson64486ae2017-03-07 15:59:08 +00004195 struct drm_i915_private *i915 = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004196
Chris Wilson64486ae2017-03-07 15:59:08 +00004197 return fault_irq_set(i915, &i915->gpu_error.missed_irq_rings, val);
Chris Wilson094f9a52013-09-25 17:34:55 +01004198}
4199
4200DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops,
4201 i915_ring_missed_irq_get, i915_ring_missed_irq_set,
4202 "0x%08llx\n");
4203
4204static int
4205i915_ring_test_irq_get(void *data, u64 *val)
4206{
David Weinehall36cdd012016-08-22 13:59:31 +03004207 struct drm_i915_private *dev_priv = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004208
4209 *val = dev_priv->gpu_error.test_irq_rings;
4210
4211 return 0;
4212}
4213
4214static int
4215i915_ring_test_irq_set(void *data, u64 val)
4216{
Chris Wilson64486ae2017-03-07 15:59:08 +00004217 struct drm_i915_private *i915 = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004218
Chris Wilson64486ae2017-03-07 15:59:08 +00004219 val &= INTEL_INFO(i915)->ring_mask;
Chris Wilson094f9a52013-09-25 17:34:55 +01004220 DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val);
Chris Wilson094f9a52013-09-25 17:34:55 +01004221
Chris Wilson64486ae2017-03-07 15:59:08 +00004222 return fault_irq_set(i915, &i915->gpu_error.test_irq_rings, val);
Chris Wilson094f9a52013-09-25 17:34:55 +01004223}
4224
4225DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops,
4226 i915_ring_test_irq_get, i915_ring_test_irq_set,
4227 "0x%08llx\n");
4228
Chris Wilsondd624af2013-01-15 12:39:35 +00004229#define DROP_UNBOUND 0x1
4230#define DROP_BOUND 0x2
4231#define DROP_RETIRE 0x4
4232#define DROP_ACTIVE 0x8
Chris Wilsonfbbd37b2016-10-28 13:58:42 +01004233#define DROP_FREED 0x10
Chris Wilson8eadc192017-03-08 14:46:22 +00004234#define DROP_SHRINK_ALL 0x20
Chris Wilsonfbbd37b2016-10-28 13:58:42 +01004235#define DROP_ALL (DROP_UNBOUND | \
4236 DROP_BOUND | \
4237 DROP_RETIRE | \
4238 DROP_ACTIVE | \
Chris Wilson8eadc192017-03-08 14:46:22 +00004239 DROP_FREED | \
4240 DROP_SHRINK_ALL)
Kees Cook647416f2013-03-10 14:10:06 -07004241static int
4242i915_drop_caches_get(void *data, u64 *val)
Chris Wilsondd624af2013-01-15 12:39:35 +00004243{
Kees Cook647416f2013-03-10 14:10:06 -07004244 *val = DROP_ALL;
Chris Wilsondd624af2013-01-15 12:39:35 +00004245
Kees Cook647416f2013-03-10 14:10:06 -07004246 return 0;
Chris Wilsondd624af2013-01-15 12:39:35 +00004247}
4248
Kees Cook647416f2013-03-10 14:10:06 -07004249static int
4250i915_drop_caches_set(void *data, u64 val)
Chris Wilsondd624af2013-01-15 12:39:35 +00004251{
David Weinehall36cdd012016-08-22 13:59:31 +03004252 struct drm_i915_private *dev_priv = data;
4253 struct drm_device *dev = &dev_priv->drm;
Chris Wilson00c26cf2017-05-24 17:26:53 +01004254 int ret = 0;
Chris Wilsondd624af2013-01-15 12:39:35 +00004255
Ben Widawsky2f9fe5f2013-11-25 09:54:37 -08004256 DRM_DEBUG("Dropping caches: 0x%08llx\n", val);
Chris Wilsondd624af2013-01-15 12:39:35 +00004257
4258 /* No need to check and wait for gpu resets, only libdrm auto-restarts
4259 * on ioctls on -EAGAIN. */
Chris Wilson00c26cf2017-05-24 17:26:53 +01004260 if (val & (DROP_ACTIVE | DROP_RETIRE)) {
4261 ret = mutex_lock_interruptible(&dev->struct_mutex);
Chris Wilsondd624af2013-01-15 12:39:35 +00004262 if (ret)
Chris Wilson00c26cf2017-05-24 17:26:53 +01004263 return ret;
Chris Wilsondd624af2013-01-15 12:39:35 +00004264
Chris Wilson00c26cf2017-05-24 17:26:53 +01004265 if (val & DROP_ACTIVE)
4266 ret = i915_gem_wait_for_idle(dev_priv,
4267 I915_WAIT_INTERRUPTIBLE |
4268 I915_WAIT_LOCKED);
4269
4270 if (val & DROP_RETIRE)
4271 i915_gem_retire_requests(dev_priv);
4272
4273 mutex_unlock(&dev->struct_mutex);
4274 }
Chris Wilsondd624af2013-01-15 12:39:35 +00004275
Peter Zijlstrad92a8cf2017-03-03 10:13:38 +01004276 fs_reclaim_acquire(GFP_KERNEL);
Chris Wilson21ab4e72014-09-09 11:16:08 +01004277 if (val & DROP_BOUND)
Chris Wilson912d5722017-09-06 16:19:30 -07004278 i915_gem_shrink(dev_priv, LONG_MAX, NULL, I915_SHRINK_BOUND);
Chris Wilson4ad72b72014-09-03 19:23:37 +01004279
Chris Wilson21ab4e72014-09-09 11:16:08 +01004280 if (val & DROP_UNBOUND)
Chris Wilson912d5722017-09-06 16:19:30 -07004281 i915_gem_shrink(dev_priv, LONG_MAX, NULL, I915_SHRINK_UNBOUND);
Chris Wilsondd624af2013-01-15 12:39:35 +00004282
Chris Wilson8eadc192017-03-08 14:46:22 +00004283 if (val & DROP_SHRINK_ALL)
4284 i915_gem_shrink_all(dev_priv);
Peter Zijlstrad92a8cf2017-03-03 10:13:38 +01004285 fs_reclaim_release(GFP_KERNEL);
Chris Wilson8eadc192017-03-08 14:46:22 +00004286
Chris Wilsonfbbd37b2016-10-28 13:58:42 +01004287 if (val & DROP_FREED) {
4288 synchronize_rcu();
Chris Wilsonbdeb9782016-12-23 14:57:56 +00004289 i915_gem_drain_freed_objects(dev_priv);
Chris Wilsonfbbd37b2016-10-28 13:58:42 +01004290 }
4291
Kees Cook647416f2013-03-10 14:10:06 -07004292 return ret;
Chris Wilsondd624af2013-01-15 12:39:35 +00004293}
4294
Kees Cook647416f2013-03-10 14:10:06 -07004295DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops,
4296 i915_drop_caches_get, i915_drop_caches_set,
4297 "0x%08llx\n");
Chris Wilsondd624af2013-01-15 12:39:35 +00004298
Kees Cook647416f2013-03-10 14:10:06 -07004299static int
4300i915_max_freq_get(void *data, u64 *val)
Jesse Barnes358733e2011-07-27 11:53:01 -07004301{
David Weinehall36cdd012016-08-22 13:59:31 +03004302 struct drm_i915_private *dev_priv = data;
Daniel Vetter004777c2012-08-09 15:07:01 +02004303
David Weinehall36cdd012016-08-22 13:59:31 +03004304 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004305 return -ENODEV;
4306
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02004307 *val = intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit);
Kees Cook647416f2013-03-10 14:10:06 -07004308 return 0;
Jesse Barnes358733e2011-07-27 11:53:01 -07004309}
4310
Kees Cook647416f2013-03-10 14:10:06 -07004311static int
4312i915_max_freq_set(void *data, u64 val)
Jesse Barnes358733e2011-07-27 11:53:01 -07004313{
David Weinehall36cdd012016-08-22 13:59:31 +03004314 struct drm_i915_private *dev_priv = data;
Akash Goelbc4d91f2015-02-26 16:09:47 +05304315 u32 hw_max, hw_min;
Kees Cook647416f2013-03-10 14:10:06 -07004316 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02004317
David Weinehall36cdd012016-08-22 13:59:31 +03004318 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004319 return -ENODEV;
Jesse Barnes358733e2011-07-27 11:53:01 -07004320
Kees Cook647416f2013-03-10 14:10:06 -07004321 DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val);
Jesse Barnes358733e2011-07-27 11:53:01 -07004322
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004323 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02004324 if (ret)
4325 return ret;
4326
Jesse Barnes358733e2011-07-27 11:53:01 -07004327 /*
4328 * Turbo will still be enabled, but won't go above the set value.
4329 */
Akash Goelbc4d91f2015-02-26 16:09:47 +05304330 val = intel_freq_opcode(dev_priv, val);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004331
Akash Goelbc4d91f2015-02-26 16:09:47 +05304332 hw_max = dev_priv->rps.max_freq;
4333 hw_min = dev_priv->rps.min_freq;
Jesse Barnes0a073b82013-04-17 15:54:58 -07004334
Ben Widawskyb39fb292014-03-19 18:31:11 -07004335 if (val < hw_min || val > hw_max || val < dev_priv->rps.min_freq_softlimit) {
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004336 mutex_unlock(&dev_priv->rps.hw_lock);
4337 return -EINVAL;
4338 }
4339
Ben Widawskyb39fb292014-03-19 18:31:11 -07004340 dev_priv->rps.max_freq_softlimit = val;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004341
Chris Wilson9fcee2f2017-01-26 10:19:19 +00004342 if (intel_set_rps(dev_priv, val))
4343 DRM_DEBUG_DRIVER("failed to update RPS to new softlimit\n");
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004344
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004345 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes358733e2011-07-27 11:53:01 -07004346
Kees Cook647416f2013-03-10 14:10:06 -07004347 return 0;
Jesse Barnes358733e2011-07-27 11:53:01 -07004348}
4349
Kees Cook647416f2013-03-10 14:10:06 -07004350DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops,
4351 i915_max_freq_get, i915_max_freq_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03004352 "%llu\n");
Jesse Barnes358733e2011-07-27 11:53:01 -07004353
Kees Cook647416f2013-03-10 14:10:06 -07004354static int
4355i915_min_freq_get(void *data, u64 *val)
Jesse Barnes1523c312012-05-25 12:34:54 -07004356{
David Weinehall36cdd012016-08-22 13:59:31 +03004357 struct drm_i915_private *dev_priv = data;
Daniel Vetter004777c2012-08-09 15:07:01 +02004358
Chris Wilson62e1baa2016-07-13 09:10:36 +01004359 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004360 return -ENODEV;
4361
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02004362 *val = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit);
Kees Cook647416f2013-03-10 14:10:06 -07004363 return 0;
Jesse Barnes1523c312012-05-25 12:34:54 -07004364}
4365
Kees Cook647416f2013-03-10 14:10:06 -07004366static int
4367i915_min_freq_set(void *data, u64 val)
Jesse Barnes1523c312012-05-25 12:34:54 -07004368{
David Weinehall36cdd012016-08-22 13:59:31 +03004369 struct drm_i915_private *dev_priv = data;
Akash Goelbc4d91f2015-02-26 16:09:47 +05304370 u32 hw_max, hw_min;
Kees Cook647416f2013-03-10 14:10:06 -07004371 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02004372
Chris Wilson62e1baa2016-07-13 09:10:36 +01004373 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004374 return -ENODEV;
Jesse Barnes1523c312012-05-25 12:34:54 -07004375
Kees Cook647416f2013-03-10 14:10:06 -07004376 DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val);
Jesse Barnes1523c312012-05-25 12:34:54 -07004377
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004378 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02004379 if (ret)
4380 return ret;
4381
Jesse Barnes1523c312012-05-25 12:34:54 -07004382 /*
4383 * Turbo will still be enabled, but won't go below the set value.
4384 */
Akash Goelbc4d91f2015-02-26 16:09:47 +05304385 val = intel_freq_opcode(dev_priv, val);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004386
Akash Goelbc4d91f2015-02-26 16:09:47 +05304387 hw_max = dev_priv->rps.max_freq;
4388 hw_min = dev_priv->rps.min_freq;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004389
David Weinehall36cdd012016-08-22 13:59:31 +03004390 if (val < hw_min ||
4391 val > hw_max || val > dev_priv->rps.max_freq_softlimit) {
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004392 mutex_unlock(&dev_priv->rps.hw_lock);
4393 return -EINVAL;
4394 }
4395
Ben Widawskyb39fb292014-03-19 18:31:11 -07004396 dev_priv->rps.min_freq_softlimit = val;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004397
Chris Wilson9fcee2f2017-01-26 10:19:19 +00004398 if (intel_set_rps(dev_priv, val))
4399 DRM_DEBUG_DRIVER("failed to update RPS to new softlimit\n");
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004400
Jesse Barnes4fc688c2012-11-02 11:14:01 -07004401 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes1523c312012-05-25 12:34:54 -07004402
Kees Cook647416f2013-03-10 14:10:06 -07004403 return 0;
Jesse Barnes1523c312012-05-25 12:34:54 -07004404}
4405
Kees Cook647416f2013-03-10 14:10:06 -07004406DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops,
4407 i915_min_freq_get, i915_min_freq_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03004408 "%llu\n");
Jesse Barnes1523c312012-05-25 12:34:54 -07004409
Kees Cook647416f2013-03-10 14:10:06 -07004410static int
4411i915_cache_sharing_get(void *data, u64 *val)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004412{
David Weinehall36cdd012016-08-22 13:59:31 +03004413 struct drm_i915_private *dev_priv = data;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004414 u32 snpcr;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004415
David Weinehall36cdd012016-08-22 13:59:31 +03004416 if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv)))
Daniel Vetter004777c2012-08-09 15:07:01 +02004417 return -ENODEV;
4418
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004419 intel_runtime_pm_get(dev_priv);
Daniel Vetter22bcfc62012-08-09 15:07:02 +02004420
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004421 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004422
4423 intel_runtime_pm_put(dev_priv);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004424
Kees Cook647416f2013-03-10 14:10:06 -07004425 *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004426
Kees Cook647416f2013-03-10 14:10:06 -07004427 return 0;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004428}
4429
Kees Cook647416f2013-03-10 14:10:06 -07004430static int
4431i915_cache_sharing_set(void *data, u64 val)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004432{
David Weinehall36cdd012016-08-22 13:59:31 +03004433 struct drm_i915_private *dev_priv = data;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004434 u32 snpcr;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004435
David Weinehall36cdd012016-08-22 13:59:31 +03004436 if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv)))
Daniel Vetter004777c2012-08-09 15:07:01 +02004437 return -ENODEV;
4438
Kees Cook647416f2013-03-10 14:10:06 -07004439 if (val > 3)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004440 return -EINVAL;
4441
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004442 intel_runtime_pm_get(dev_priv);
Kees Cook647416f2013-03-10 14:10:06 -07004443 DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004444
4445 /* Update the cache sharing policy here as well */
4446 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
4447 snpcr &= ~GEN6_MBC_SNPCR_MASK;
4448 snpcr |= (val << GEN6_MBC_SNPCR_SHIFT);
4449 I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr);
4450
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004451 intel_runtime_pm_put(dev_priv);
Kees Cook647416f2013-03-10 14:10:06 -07004452 return 0;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004453}
4454
Kees Cook647416f2013-03-10 14:10:06 -07004455DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops,
4456 i915_cache_sharing_get, i915_cache_sharing_set,
4457 "%llu\n");
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004458
David Weinehall36cdd012016-08-22 13:59:31 +03004459static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv,
Imre Deak915490d2016-08-31 19:13:01 +03004460 struct sseu_dev_info *sseu)
Jeff McGee5d395252015-04-03 18:13:17 -07004461{
Ville Syrjälä0a0b4572015-08-21 20:45:27 +03004462 int ss_max = 2;
Jeff McGee5d395252015-04-03 18:13:17 -07004463 int ss;
4464 u32 sig1[ss_max], sig2[ss_max];
4465
4466 sig1[0] = I915_READ(CHV_POWER_SS0_SIG1);
4467 sig1[1] = I915_READ(CHV_POWER_SS1_SIG1);
4468 sig2[0] = I915_READ(CHV_POWER_SS0_SIG2);
4469 sig2[1] = I915_READ(CHV_POWER_SS1_SIG2);
4470
4471 for (ss = 0; ss < ss_max; ss++) {
4472 unsigned int eu_cnt;
4473
4474 if (sig1[ss] & CHV_SS_PG_ENABLE)
4475 /* skip disabled subslice */
4476 continue;
4477
Imre Deakf08a0c92016-08-31 19:13:04 +03004478 sseu->slice_mask = BIT(0);
Imre Deak57ec1712016-08-31 19:13:05 +03004479 sseu->subslice_mask |= BIT(ss);
Jeff McGee5d395252015-04-03 18:13:17 -07004480 eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) +
4481 ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) +
4482 ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) +
4483 ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2);
Imre Deak915490d2016-08-31 19:13:01 +03004484 sseu->eu_total += eu_cnt;
4485 sseu->eu_per_subslice = max_t(unsigned int,
4486 sseu->eu_per_subslice, eu_cnt);
Jeff McGee5d395252015-04-03 18:13:17 -07004487 }
Jeff McGee5d395252015-04-03 18:13:17 -07004488}
4489
David Weinehall36cdd012016-08-22 13:59:31 +03004490static void gen9_sseu_device_status(struct drm_i915_private *dev_priv,
Imre Deak915490d2016-08-31 19:13:01 +03004491 struct sseu_dev_info *sseu)
Jeff McGee5d395252015-04-03 18:13:17 -07004492{
Jeff McGee1c046bc2015-04-03 18:13:18 -07004493 int s_max = 3, ss_max = 4;
Jeff McGee5d395252015-04-03 18:13:17 -07004494 int s, ss;
4495 u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2];
4496
Jeff McGee1c046bc2015-04-03 18:13:18 -07004497 /* BXT has a single slice and at most 3 subslices. */
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02004498 if (IS_GEN9_LP(dev_priv)) {
Jeff McGee1c046bc2015-04-03 18:13:18 -07004499 s_max = 1;
4500 ss_max = 3;
4501 }
4502
4503 for (s = 0; s < s_max; s++) {
4504 s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s));
4505 eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s));
4506 eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s));
4507 }
4508
Jeff McGee5d395252015-04-03 18:13:17 -07004509 eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK |
4510 GEN9_PGCTL_SSA_EU19_ACK |
4511 GEN9_PGCTL_SSA_EU210_ACK |
4512 GEN9_PGCTL_SSA_EU311_ACK;
4513 eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK |
4514 GEN9_PGCTL_SSB_EU19_ACK |
4515 GEN9_PGCTL_SSB_EU210_ACK |
4516 GEN9_PGCTL_SSB_EU311_ACK;
4517
4518 for (s = 0; s < s_max; s++) {
4519 if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0)
4520 /* skip disabled slice */
4521 continue;
4522
Imre Deakf08a0c92016-08-31 19:13:04 +03004523 sseu->slice_mask |= BIT(s);
Jeff McGee1c046bc2015-04-03 18:13:18 -07004524
Rodrigo Vivi7ea1adf2017-08-09 13:07:02 -07004525 if (IS_GEN9_BC(dev_priv) || IS_CANNONLAKE(dev_priv))
Imre Deak57ec1712016-08-31 19:13:05 +03004526 sseu->subslice_mask =
4527 INTEL_INFO(dev_priv)->sseu.subslice_mask;
Jeff McGee1c046bc2015-04-03 18:13:18 -07004528
Jeff McGee5d395252015-04-03 18:13:17 -07004529 for (ss = 0; ss < ss_max; ss++) {
4530 unsigned int eu_cnt;
4531
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02004532 if (IS_GEN9_LP(dev_priv)) {
Imre Deak57ec1712016-08-31 19:13:05 +03004533 if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss))))
4534 /* skip disabled subslice */
4535 continue;
Jeff McGee1c046bc2015-04-03 18:13:18 -07004536
Imre Deak57ec1712016-08-31 19:13:05 +03004537 sseu->subslice_mask |= BIT(ss);
4538 }
Jeff McGee1c046bc2015-04-03 18:13:18 -07004539
Jeff McGee5d395252015-04-03 18:13:17 -07004540 eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] &
4541 eu_mask[ss%2]);
Imre Deak915490d2016-08-31 19:13:01 +03004542 sseu->eu_total += eu_cnt;
4543 sseu->eu_per_subslice = max_t(unsigned int,
4544 sseu->eu_per_subslice,
4545 eu_cnt);
Jeff McGee5d395252015-04-03 18:13:17 -07004546 }
4547 }
4548}
4549
David Weinehall36cdd012016-08-22 13:59:31 +03004550static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv,
Imre Deak915490d2016-08-31 19:13:01 +03004551 struct sseu_dev_info *sseu)
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004552{
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004553 u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO);
David Weinehall36cdd012016-08-22 13:59:31 +03004554 int s;
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004555
Imre Deakf08a0c92016-08-31 19:13:04 +03004556 sseu->slice_mask = slice_info & GEN8_LSLICESTAT_MASK;
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004557
Imre Deakf08a0c92016-08-31 19:13:04 +03004558 if (sseu->slice_mask) {
Imre Deak57ec1712016-08-31 19:13:05 +03004559 sseu->subslice_mask = INTEL_INFO(dev_priv)->sseu.subslice_mask;
Imre Deak43b67992016-08-31 19:13:02 +03004560 sseu->eu_per_subslice =
4561 INTEL_INFO(dev_priv)->sseu.eu_per_subslice;
Imre Deak57ec1712016-08-31 19:13:05 +03004562 sseu->eu_total = sseu->eu_per_subslice *
4563 sseu_subslice_total(sseu);
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004564
4565 /* subtract fused off EU(s) from enabled slice(s) */
Imre Deak795b38b2016-08-31 19:13:07 +03004566 for (s = 0; s < fls(sseu->slice_mask); s++) {
Imre Deak43b67992016-08-31 19:13:02 +03004567 u8 subslice_7eu =
4568 INTEL_INFO(dev_priv)->sseu.subslice_7eu[s];
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004569
Imre Deak915490d2016-08-31 19:13:01 +03004570 sseu->eu_total -= hweight8(subslice_7eu);
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004571 }
4572 }
4573}
4574
Imre Deak615d8902016-08-31 19:13:03 +03004575static void i915_print_sseu_info(struct seq_file *m, bool is_available_info,
4576 const struct sseu_dev_info *sseu)
4577{
4578 struct drm_i915_private *dev_priv = node_to_i915(m->private);
4579 const char *type = is_available_info ? "Available" : "Enabled";
4580
Imre Deakc67ba532016-08-31 19:13:06 +03004581 seq_printf(m, " %s Slice Mask: %04x\n", type,
4582 sseu->slice_mask);
Imre Deak615d8902016-08-31 19:13:03 +03004583 seq_printf(m, " %s Slice Total: %u\n", type,
Imre Deakf08a0c92016-08-31 19:13:04 +03004584 hweight8(sseu->slice_mask));
Imre Deak615d8902016-08-31 19:13:03 +03004585 seq_printf(m, " %s Subslice Total: %u\n", type,
Imre Deak57ec1712016-08-31 19:13:05 +03004586 sseu_subslice_total(sseu));
Imre Deakc67ba532016-08-31 19:13:06 +03004587 seq_printf(m, " %s Subslice Mask: %04x\n", type,
4588 sseu->subslice_mask);
Imre Deak615d8902016-08-31 19:13:03 +03004589 seq_printf(m, " %s Subslice Per Slice: %u\n", type,
Imre Deak57ec1712016-08-31 19:13:05 +03004590 hweight8(sseu->subslice_mask));
Imre Deak615d8902016-08-31 19:13:03 +03004591 seq_printf(m, " %s EU Total: %u\n", type,
4592 sseu->eu_total);
4593 seq_printf(m, " %s EU Per Subslice: %u\n", type,
4594 sseu->eu_per_subslice);
4595
4596 if (!is_available_info)
4597 return;
4598
4599 seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv)));
4600 if (HAS_POOLED_EU(dev_priv))
4601 seq_printf(m, " Min EU in pool: %u\n", sseu->min_eu_in_pool);
4602
4603 seq_printf(m, " Has Slice Power Gating: %s\n",
4604 yesno(sseu->has_slice_pg));
4605 seq_printf(m, " Has Subslice Power Gating: %s\n",
4606 yesno(sseu->has_subslice_pg));
4607 seq_printf(m, " Has EU Power Gating: %s\n",
4608 yesno(sseu->has_eu_pg));
4609}
4610
Jeff McGee38732182015-02-13 10:27:54 -06004611static int i915_sseu_status(struct seq_file *m, void *unused)
4612{
David Weinehall36cdd012016-08-22 13:59:31 +03004613 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Imre Deak915490d2016-08-31 19:13:01 +03004614 struct sseu_dev_info sseu;
Jeff McGee38732182015-02-13 10:27:54 -06004615
David Weinehall36cdd012016-08-22 13:59:31 +03004616 if (INTEL_GEN(dev_priv) < 8)
Jeff McGee38732182015-02-13 10:27:54 -06004617 return -ENODEV;
4618
4619 seq_puts(m, "SSEU Device Info\n");
Imre Deak615d8902016-08-31 19:13:03 +03004620 i915_print_sseu_info(m, true, &INTEL_INFO(dev_priv)->sseu);
Jeff McGee38732182015-02-13 10:27:54 -06004621
Jeff McGee7f992ab2015-02-13 10:27:55 -06004622 seq_puts(m, "SSEU Device Status\n");
Imre Deak915490d2016-08-31 19:13:01 +03004623 memset(&sseu, 0, sizeof(sseu));
David Weinehall238010e2016-08-01 17:33:27 +03004624
4625 intel_runtime_pm_get(dev_priv);
4626
David Weinehall36cdd012016-08-22 13:59:31 +03004627 if (IS_CHERRYVIEW(dev_priv)) {
Imre Deak915490d2016-08-31 19:13:01 +03004628 cherryview_sseu_device_status(dev_priv, &sseu);
David Weinehall36cdd012016-08-22 13:59:31 +03004629 } else if (IS_BROADWELL(dev_priv)) {
Imre Deak915490d2016-08-31 19:13:01 +03004630 broadwell_sseu_device_status(dev_priv, &sseu);
David Weinehall36cdd012016-08-22 13:59:31 +03004631 } else if (INTEL_GEN(dev_priv) >= 9) {
Imre Deak915490d2016-08-31 19:13:01 +03004632 gen9_sseu_device_status(dev_priv, &sseu);
Jeff McGee7f992ab2015-02-13 10:27:55 -06004633 }
David Weinehall238010e2016-08-01 17:33:27 +03004634
4635 intel_runtime_pm_put(dev_priv);
4636
Imre Deak615d8902016-08-31 19:13:03 +03004637 i915_print_sseu_info(m, false, &sseu);
Jeff McGee7f992ab2015-02-13 10:27:55 -06004638
Jeff McGee38732182015-02-13 10:27:54 -06004639 return 0;
4640}
4641
Ben Widawsky6d794d42011-04-25 11:25:56 -07004642static int i915_forcewake_open(struct inode *inode, struct file *file)
4643{
Chris Wilsond7a133d2017-09-07 14:44:41 +01004644 struct drm_i915_private *i915 = inode->i_private;
Ben Widawsky6d794d42011-04-25 11:25:56 -07004645
Chris Wilsond7a133d2017-09-07 14:44:41 +01004646 if (INTEL_GEN(i915) < 6)
Ben Widawsky6d794d42011-04-25 11:25:56 -07004647 return 0;
4648
Chris Wilsond7a133d2017-09-07 14:44:41 +01004649 intel_runtime_pm_get(i915);
4650 intel_uncore_forcewake_user_get(i915);
Ben Widawsky6d794d42011-04-25 11:25:56 -07004651
4652 return 0;
4653}
4654
Ben Widawskyc43b5632012-04-16 14:07:40 -07004655static int i915_forcewake_release(struct inode *inode, struct file *file)
Ben Widawsky6d794d42011-04-25 11:25:56 -07004656{
Chris Wilsond7a133d2017-09-07 14:44:41 +01004657 struct drm_i915_private *i915 = inode->i_private;
Ben Widawsky6d794d42011-04-25 11:25:56 -07004658
Chris Wilsond7a133d2017-09-07 14:44:41 +01004659 if (INTEL_GEN(i915) < 6)
Ben Widawsky6d794d42011-04-25 11:25:56 -07004660 return 0;
4661
Chris Wilsond7a133d2017-09-07 14:44:41 +01004662 intel_uncore_forcewake_user_put(i915);
4663 intel_runtime_pm_put(i915);
Ben Widawsky6d794d42011-04-25 11:25:56 -07004664
4665 return 0;
4666}
4667
4668static const struct file_operations i915_forcewake_fops = {
4669 .owner = THIS_MODULE,
4670 .open = i915_forcewake_open,
4671 .release = i915_forcewake_release,
4672};
4673
Lyude317eaa92017-02-03 21:18:25 -05004674static int i915_hpd_storm_ctl_show(struct seq_file *m, void *data)
4675{
4676 struct drm_i915_private *dev_priv = m->private;
4677 struct i915_hotplug *hotplug = &dev_priv->hotplug;
4678
4679 seq_printf(m, "Threshold: %d\n", hotplug->hpd_storm_threshold);
4680 seq_printf(m, "Detected: %s\n",
4681 yesno(delayed_work_pending(&hotplug->reenable_work)));
4682
4683 return 0;
4684}
4685
4686static ssize_t i915_hpd_storm_ctl_write(struct file *file,
4687 const char __user *ubuf, size_t len,
4688 loff_t *offp)
4689{
4690 struct seq_file *m = file->private_data;
4691 struct drm_i915_private *dev_priv = m->private;
4692 struct i915_hotplug *hotplug = &dev_priv->hotplug;
4693 unsigned int new_threshold;
4694 int i;
4695 char *newline;
4696 char tmp[16];
4697
4698 if (len >= sizeof(tmp))
4699 return -EINVAL;
4700
4701 if (copy_from_user(tmp, ubuf, len))
4702 return -EFAULT;
4703
4704 tmp[len] = '\0';
4705
4706 /* Strip newline, if any */
4707 newline = strchr(tmp, '\n');
4708 if (newline)
4709 *newline = '\0';
4710
4711 if (strcmp(tmp, "reset") == 0)
4712 new_threshold = HPD_STORM_DEFAULT_THRESHOLD;
4713 else if (kstrtouint(tmp, 10, &new_threshold) != 0)
4714 return -EINVAL;
4715
4716 if (new_threshold > 0)
4717 DRM_DEBUG_KMS("Setting HPD storm detection threshold to %d\n",
4718 new_threshold);
4719 else
4720 DRM_DEBUG_KMS("Disabling HPD storm detection\n");
4721
4722 spin_lock_irq(&dev_priv->irq_lock);
4723 hotplug->hpd_storm_threshold = new_threshold;
4724 /* Reset the HPD storm stats so we don't accidentally trigger a storm */
4725 for_each_hpd_pin(i)
4726 hotplug->stats[i].count = 0;
4727 spin_unlock_irq(&dev_priv->irq_lock);
4728
4729 /* Re-enable hpd immediately if we were in an irq storm */
4730 flush_delayed_work(&dev_priv->hotplug.reenable_work);
4731
4732 return len;
4733}
4734
4735static int i915_hpd_storm_ctl_open(struct inode *inode, struct file *file)
4736{
4737 return single_open(file, i915_hpd_storm_ctl_show, inode->i_private);
4738}
4739
4740static const struct file_operations i915_hpd_storm_ctl_fops = {
4741 .owner = THIS_MODULE,
4742 .open = i915_hpd_storm_ctl_open,
4743 .read = seq_read,
4744 .llseek = seq_lseek,
4745 .release = single_release,
4746 .write = i915_hpd_storm_ctl_write
4747};
4748
Lespiau, Damien06c5bf82013-10-17 19:09:56 +01004749static const struct drm_info_list i915_debugfs_list[] = {
Chris Wilson311bd682011-01-13 19:06:50 +00004750 {"i915_capabilities", i915_capabilities, 0},
Chris Wilson73aa8082010-09-30 11:46:12 +01004751 {"i915_gem_objects", i915_gem_object_info, 0},
Chris Wilson08c18322011-01-10 00:00:24 +00004752 {"i915_gem_gtt", i915_gem_gtt_info, 0},
Chris Wilson6da84822016-08-15 10:48:44 +01004753 {"i915_gem_pin_display", i915_gem_gtt_info, 0, (void *)1},
Chris Wilson6d2b88852013-08-07 18:30:54 +01004754 {"i915_gem_stolen", i915_gem_stolen_list_info },
Ben Gamari20172632009-02-17 20:08:50 -05004755 {"i915_gem_request", i915_gem_request_info, 0},
4756 {"i915_gem_seqno", i915_gem_seqno_info, 0},
Chris Wilsona6172a82009-02-11 14:26:38 +00004757 {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05004758 {"i915_gem_interrupt", i915_interrupt_info, 0},
Brad Volkin493018d2014-12-11 12:13:08 -08004759 {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0},
Dave Gordon8b417c22015-08-12 15:43:44 +01004760 {"i915_guc_info", i915_guc_info, 0},
Alex Daifdf5d352015-08-12 15:43:37 +01004761 {"i915_guc_load_status", i915_guc_load_status_info, 0},
Alex Dai4c7e77f2015-08-12 15:43:40 +01004762 {"i915_guc_log_dump", i915_guc_log_dump, 0},
Daniele Ceraolo Spurioac58d2a2017-05-22 10:50:28 -07004763 {"i915_guc_load_err_log_dump", i915_guc_log_dump, 0, (void *)1},
Oscar Mateoa8b93702017-05-10 15:04:51 +00004764 {"i915_guc_stage_pool", i915_guc_stage_pool, 0},
Anusha Srivatsa0509ead2017-01-18 08:05:56 -08004765 {"i915_huc_load_status", i915_huc_load_status_info, 0},
Deepak Sadb4bd12014-03-31 11:30:02 +05304766 {"i915_frequency_info", i915_frequency_info, 0},
Chris Wilsonf6544492015-01-26 18:03:04 +02004767 {"i915_hangcheck_info", i915_hangcheck_info, 0},
Michel Thierry061d06a2017-06-20 10:57:49 +01004768 {"i915_reset_info", i915_reset_info, 0},
Jesse Barnesf97108d2010-01-29 11:27:07 -08004769 {"i915_drpc_info", i915_drpc_info, 0},
Jesse Barnes7648fa92010-05-20 14:28:11 -07004770 {"i915_emon_status", i915_emon_status, 0},
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07004771 {"i915_ring_freq_table", i915_ring_freq_table, 0},
Daniel Vetter9a851782015-06-18 10:30:22 +02004772 {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0},
Jesse Barnesb5e50c32010-02-05 12:42:41 -08004773 {"i915_fbc_status", i915_fbc_status, 0},
Paulo Zanoni92d44622013-05-31 16:33:24 -03004774 {"i915_ips_status", i915_ips_status, 0},
Jesse Barnes4a9bef32010-02-05 12:47:35 -08004775 {"i915_sr_status", i915_sr_status, 0},
Chris Wilson44834a62010-08-19 16:09:23 +01004776 {"i915_opregion", i915_opregion, 0},
Jani Nikulaada8f952015-12-15 13:17:12 +02004777 {"i915_vbt", i915_vbt, 0},
Chris Wilson37811fc2010-08-25 22:45:57 +01004778 {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
Ben Widawskye76d3632011-03-19 18:14:29 -07004779 {"i915_context_status", i915_context_status, 0},
Ben Widawskyc0ab1ae92014-08-07 13:24:26 +01004780 {"i915_dump_lrc", i915_dump_lrc, 0},
Mika Kuoppalaf65367b2015-01-16 11:34:42 +02004781 {"i915_forcewake_domains", i915_forcewake_domains, 0},
Daniel Vetterea16a3c2011-12-14 13:57:16 +01004782 {"i915_swizzle_info", i915_swizzle_info, 0},
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01004783 {"i915_ppgtt_info", i915_ppgtt_info, 0},
Ben Widawsky63573eb2013-07-04 11:02:07 -07004784 {"i915_llc", i915_llc, 0},
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03004785 {"i915_edp_psr_status", i915_edp_psr_status, 0},
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02004786 {"i915_sink_crc_eDP1", i915_sink_crc, 0},
Jesse Barnesec013e72013-08-20 10:29:23 +01004787 {"i915_energy_uJ", i915_energy_uJ, 0},
Damien Lespiau6455c872015-06-04 18:23:57 +01004788 {"i915_runtime_pm_status", i915_runtime_pm_status, 0},
Imre Deak1da51582013-11-25 17:15:35 +02004789 {"i915_power_domain_info", i915_power_domain_info, 0},
Damien Lespiaub7cec662015-10-27 14:47:01 +02004790 {"i915_dmc_info", i915_dmc_info, 0},
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08004791 {"i915_display_info", i915_display_info, 0},
Chris Wilson1b365952016-10-04 21:11:31 +01004792 {"i915_engine_info", i915_engine_info, 0},
Ben Widawskye04934c2014-06-30 09:53:42 -07004793 {"i915_semaphore_status", i915_semaphore_status, 0},
Daniel Vetter728e29d2014-06-25 22:01:53 +03004794 {"i915_shared_dplls_info", i915_shared_dplls_info, 0},
Dave Airlie11bed952014-05-12 15:22:27 +10004795 {"i915_dp_mst_info", i915_dp_mst_info, 0},
Damien Lespiau1ed1ef92014-08-30 16:50:59 +01004796 {"i915_wa_registers", i915_wa_registers, 0},
Damien Lespiauc5511e42014-11-04 17:06:51 +00004797 {"i915_ddb_info", i915_ddb_info, 0},
Jeff McGee38732182015-02-13 10:27:54 -06004798 {"i915_sseu_status", i915_sseu_status, 0},
Vandana Kannana54746e2015-03-03 20:53:10 +05304799 {"i915_drrs_status", i915_drrs_status, 0},
Chris Wilson1854d5c2015-04-07 16:20:32 +01004800 {"i915_rps_boost_info", i915_rps_boost_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05004801};
Ben Gamari27c202a2009-07-01 22:26:52 -04004802#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
Ben Gamari20172632009-02-17 20:08:50 -05004803
Lespiau, Damien06c5bf82013-10-17 19:09:56 +01004804static const struct i915_debugfs_files {
Daniel Vetter34b96742013-07-04 20:49:44 +02004805 const char *name;
4806 const struct file_operations *fops;
4807} i915_debugfs_files[] = {
4808 {"i915_wedged", &i915_wedged_fops},
4809 {"i915_max_freq", &i915_max_freq_fops},
4810 {"i915_min_freq", &i915_min_freq_fops},
4811 {"i915_cache_sharing", &i915_cache_sharing_fops},
Chris Wilson094f9a52013-09-25 17:34:55 +01004812 {"i915_ring_missed_irq", &i915_ring_missed_irq_fops},
4813 {"i915_ring_test_irq", &i915_ring_test_irq_fops},
Daniel Vetter34b96742013-07-04 20:49:44 +02004814 {"i915_gem_drop_caches", &i915_drop_caches_fops},
Chris Wilson98a2f412016-10-12 10:05:18 +01004815#if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR)
Daniel Vetter34b96742013-07-04 20:49:44 +02004816 {"i915_error_state", &i915_error_state_fops},
Chris Wilson5a4c6f12017-02-14 16:46:11 +00004817 {"i915_gpu_info", &i915_gpu_info_fops},
Chris Wilson98a2f412016-10-12 10:05:18 +01004818#endif
Daniel Vetter34b96742013-07-04 20:49:44 +02004819 {"i915_next_seqno", &i915_next_seqno_fops},
Damien Lespiaubd9db022013-10-15 18:55:36 +01004820 {"i915_display_crc_ctl", &i915_display_crc_ctl_fops},
Ville Syrjälä369a1342014-01-22 14:36:08 +02004821 {"i915_pri_wm_latency", &i915_pri_wm_latency_fops},
4822 {"i915_spr_wm_latency", &i915_spr_wm_latency_fops},
4823 {"i915_cur_wm_latency", &i915_cur_wm_latency_fops},
Ville Syrjälä4127dc42017-06-06 15:44:12 +03004824 {"i915_fbc_false_color", &i915_fbc_false_color_fops},
Todd Previteeb3394fa2015-04-18 00:04:19 -07004825 {"i915_dp_test_data", &i915_displayport_test_data_fops},
4826 {"i915_dp_test_type", &i915_displayport_test_type_fops},
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05304827 {"i915_dp_test_active", &i915_displayport_test_active_fops},
Lyude317eaa92017-02-03 21:18:25 -05004828 {"i915_guc_log_control", &i915_guc_log_control_fops},
Kumar, Maheshd2d4f392017-08-17 19:15:29 +05304829 {"i915_hpd_storm_ctl", &i915_hpd_storm_ctl_fops},
4830 {"i915_ipc_status", &i915_ipc_status_fops}
Daniel Vetter34b96742013-07-04 20:49:44 +02004831};
4832
Chris Wilson1dac8912016-06-24 14:00:17 +01004833int i915_debugfs_register(struct drm_i915_private *dev_priv)
Ben Gamari20172632009-02-17 20:08:50 -05004834{
Chris Wilson91c8a322016-07-05 10:40:23 +01004835 struct drm_minor *minor = dev_priv->drm.primary;
Noralf Trønnesb05eeb02017-01-26 23:56:21 +01004836 struct dentry *ent;
Daniel Vetter34b96742013-07-04 20:49:44 +02004837 int ret, i;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004838
Noralf Trønnesb05eeb02017-01-26 23:56:21 +01004839 ent = debugfs_create_file("i915_forcewake_user", S_IRUSR,
4840 minor->debugfs_root, to_i915(minor->dev),
4841 &i915_forcewake_fops);
4842 if (!ent)
4843 return -ENOMEM;
Daniel Vetter6a9c3082011-12-14 13:57:11 +01004844
Tomeu Vizoso731035f2016-12-12 13:29:48 +01004845 ret = intel_pipe_crc_create(minor);
4846 if (ret)
4847 return ret;
Damien Lespiau07144422013-10-15 18:55:40 +01004848
Daniel Vetter34b96742013-07-04 20:49:44 +02004849 for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
Noralf Trønnesb05eeb02017-01-26 23:56:21 +01004850 ent = debugfs_create_file(i915_debugfs_files[i].name,
4851 S_IRUGO | S_IWUSR,
4852 minor->debugfs_root,
4853 to_i915(minor->dev),
Daniel Vetter34b96742013-07-04 20:49:44 +02004854 i915_debugfs_files[i].fops);
Noralf Trønnesb05eeb02017-01-26 23:56:21 +01004855 if (!ent)
4856 return -ENOMEM;
Daniel Vetter34b96742013-07-04 20:49:44 +02004857 }
Mika Kuoppala40633212012-12-04 15:12:00 +02004858
Ben Gamari27c202a2009-07-01 22:26:52 -04004859 return drm_debugfs_create_files(i915_debugfs_list,
4860 I915_DEBUGFS_ENTRIES,
Ben Gamari20172632009-02-17 20:08:50 -05004861 minor->debugfs_root, minor);
4862}
4863
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004864struct dpcd_block {
4865 /* DPCD dump start address. */
4866 unsigned int offset;
4867 /* DPCD dump end address, inclusive. If unset, .size will be used. */
4868 unsigned int end;
4869 /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */
4870 size_t size;
4871 /* Only valid for eDP. */
4872 bool edp;
4873};
4874
4875static const struct dpcd_block i915_dpcd_debug[] = {
4876 { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE },
4877 { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS },
4878 { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 },
4879 { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET },
4880 { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 },
4881 { .offset = DP_SET_POWER },
4882 { .offset = DP_EDP_DPCD_REV },
4883 { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 },
4884 { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB },
4885 { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET },
4886};
4887
4888static int i915_dpcd_show(struct seq_file *m, void *data)
4889{
4890 struct drm_connector *connector = m->private;
4891 struct intel_dp *intel_dp =
4892 enc_to_intel_dp(&intel_attached_encoder(connector)->base);
4893 uint8_t buf[16];
4894 ssize_t err;
4895 int i;
4896
Mika Kuoppala5c1a8872015-05-15 13:09:21 +03004897 if (connector->status != connector_status_connected)
4898 return -ENODEV;
4899
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004900 for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) {
4901 const struct dpcd_block *b = &i915_dpcd_debug[i];
4902 size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1);
4903
4904 if (b->edp &&
4905 connector->connector_type != DRM_MODE_CONNECTOR_eDP)
4906 continue;
4907
4908 /* low tech for now */
4909 if (WARN_ON(size > sizeof(buf)))
4910 continue;
4911
4912 err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size);
4913 if (err <= 0) {
4914 DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n",
4915 size, b->offset, err);
4916 continue;
4917 }
4918
4919 seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf);
kbuild test robotb3f9d7d2015-04-16 18:34:06 +08004920 }
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004921
4922 return 0;
4923}
4924
4925static int i915_dpcd_open(struct inode *inode, struct file *file)
4926{
4927 return single_open(file, i915_dpcd_show, inode->i_private);
4928}
4929
4930static const struct file_operations i915_dpcd_fops = {
4931 .owner = THIS_MODULE,
4932 .open = i915_dpcd_open,
4933 .read = seq_read,
4934 .llseek = seq_lseek,
4935 .release = single_release,
4936};
4937
David Weinehallecbd6782016-08-23 12:23:56 +03004938static int i915_panel_show(struct seq_file *m, void *data)
4939{
4940 struct drm_connector *connector = m->private;
4941 struct intel_dp *intel_dp =
4942 enc_to_intel_dp(&intel_attached_encoder(connector)->base);
4943
4944 if (connector->status != connector_status_connected)
4945 return -ENODEV;
4946
4947 seq_printf(m, "Panel power up delay: %d\n",
4948 intel_dp->panel_power_up_delay);
4949 seq_printf(m, "Panel power down delay: %d\n",
4950 intel_dp->panel_power_down_delay);
4951 seq_printf(m, "Backlight on delay: %d\n",
4952 intel_dp->backlight_on_delay);
4953 seq_printf(m, "Backlight off delay: %d\n",
4954 intel_dp->backlight_off_delay);
4955
4956 return 0;
4957}
4958
4959static int i915_panel_open(struct inode *inode, struct file *file)
4960{
4961 return single_open(file, i915_panel_show, inode->i_private);
4962}
4963
4964static const struct file_operations i915_panel_fops = {
4965 .owner = THIS_MODULE,
4966 .open = i915_panel_open,
4967 .read = seq_read,
4968 .llseek = seq_lseek,
4969 .release = single_release,
4970};
4971
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004972/**
4973 * i915_debugfs_connector_add - add i915 specific connector debugfs files
4974 * @connector: pointer to a registered drm_connector
4975 *
4976 * Cleanup will be done by drm_connector_unregister() through a call to
4977 * drm_debugfs_connector_remove().
4978 *
4979 * Returns 0 on success, negative error codes on error.
4980 */
4981int i915_debugfs_connector_add(struct drm_connector *connector)
4982{
4983 struct dentry *root = connector->debugfs_entry;
4984
4985 /* The connector must have been registered beforehands. */
4986 if (!root)
4987 return -ENODEV;
4988
4989 if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
4990 connector->connector_type == DRM_MODE_CONNECTOR_eDP)
David Weinehallecbd6782016-08-23 12:23:56 +03004991 debugfs_create_file("i915_dpcd", S_IRUGO, root,
4992 connector, &i915_dpcd_fops);
4993
4994 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP)
4995 debugfs_create_file("i915_panel_timings", S_IRUGO, root,
4996 connector, &i915_panel_fops);
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004997
4998 return 0;
4999}