blob: 39883cd915db1d0d5328f046a9e0ce8775317a34 [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{
Chris Wilsonbd3d2252017-10-13 21:26:14 +010086 return obj->pin_global ? 'p' : ' ';
Tvrtko Ursulinbe12a862016-04-15 11:34:52 +010087}
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 Wilsonbd3d2252017-10-13 21:26:14 +0100183 if (obj->pin_global)
184 seq_printf(m, " (global)");
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;
Chris Wilsonf2123812017-10-16 12:40:37 +0100274
275 spin_lock(&dev_priv->mm.obj_lock);
276 list_for_each_entry(obj, &dev_priv->mm.bound_list, mm.link) {
Chris Wilsone637d2c2017-03-16 13:19:57 +0000277 if (count == total)
278 break;
279
Chris Wilson6d2b88852013-08-07 18:30:54 +0100280 if (obj->stolen == NULL)
281 continue;
282
Chris Wilsone637d2c2017-03-16 13:19:57 +0000283 objects[count++] = obj;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100284 total_obj_size += obj->base.size;
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100285 total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
Chris Wilsone637d2c2017-03-16 13:19:57 +0000286
Chris Wilson6d2b88852013-08-07 18:30:54 +0100287 }
Chris Wilsonf2123812017-10-16 12:40:37 +0100288 list_for_each_entry(obj, &dev_priv->mm.unbound_list, mm.link) {
Chris Wilsone637d2c2017-03-16 13:19:57 +0000289 if (count == total)
290 break;
291
Chris Wilson6d2b88852013-08-07 18:30:54 +0100292 if (obj->stolen == NULL)
293 continue;
294
Chris Wilsone637d2c2017-03-16 13:19:57 +0000295 objects[count++] = obj;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100296 total_obj_size += obj->base.size;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100297 }
Chris Wilsonf2123812017-10-16 12:40:37 +0100298 spin_unlock(&dev_priv->mm.obj_lock);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100299
Chris Wilsone637d2c2017-03-16 13:19:57 +0000300 sort(objects, count, sizeof(*objects), obj_rank_by_stolen, NULL);
301
302 seq_puts(m, "Stolen:\n");
303 for (n = 0; n < count; n++) {
304 seq_puts(m, " ");
305 describe_obj(m, objects[n]);
306 seq_putc(m, '\n');
307 }
308 seq_printf(m, "Total %lu objects, %llu bytes, %llu GTT size\n",
Chris Wilson6d2b88852013-08-07 18:30:54 +0100309 count, total_obj_size, total_gtt_size);
Chris Wilsone637d2c2017-03-16 13:19:57 +0000310
311 mutex_unlock(&dev->struct_mutex);
312out:
Michal Hocko20981052017-05-17 14:23:12 +0200313 kvfree(objects);
Chris Wilsone637d2c2017-03-16 13:19:57 +0000314 return ret;
Chris Wilson6d2b88852013-08-07 18:30:54 +0100315}
316
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100317struct file_stats {
Chris Wilson6313c202014-03-19 13:45:45 +0000318 struct drm_i915_file_private *file_priv;
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300319 unsigned long count;
320 u64 total, unbound;
321 u64 global, shared;
322 u64 active, inactive;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100323};
324
325static int per_file_stats(int id, void *ptr, void *data)
326{
327 struct drm_i915_gem_object *obj = ptr;
328 struct file_stats *stats = data;
Chris Wilson6313c202014-03-19 13:45:45 +0000329 struct i915_vma *vma;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100330
Chris Wilson0caf81b2017-06-17 12:57:44 +0100331 lockdep_assert_held(&obj->base.dev->struct_mutex);
332
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100333 stats->count++;
334 stats->total += obj->base.size;
Chris Wilson15717de2016-08-04 07:52:26 +0100335 if (!obj->bind_count)
336 stats->unbound += obj->base.size;
Chris Wilsonc67a17e2014-03-19 13:45:46 +0000337 if (obj->base.name || obj->base.dma_buf)
338 stats->shared += obj->base.size;
339
Chris Wilson894eeec2016-08-04 07:52:20 +0100340 list_for_each_entry(vma, &obj->vma_list, obj_link) {
341 if (!drm_mm_node_allocated(&vma->node))
342 continue;
Chris Wilson6313c202014-03-19 13:45:45 +0000343
Chris Wilson3272db52016-08-04 16:32:32 +0100344 if (i915_vma_is_ggtt(vma)) {
Chris Wilson894eeec2016-08-04 07:52:20 +0100345 stats->global += vma->node.size;
346 } else {
347 struct i915_hw_ppgtt *ppgtt = i915_vm_to_ppgtt(vma->vm);
Chris Wilson6313c202014-03-19 13:45:45 +0000348
Chris Wilson2bfa9962016-08-04 07:52:25 +0100349 if (ppgtt->base.file != stats->file_priv)
Chris Wilson6313c202014-03-19 13:45:45 +0000350 continue;
Chris Wilson6313c202014-03-19 13:45:45 +0000351 }
Chris Wilson894eeec2016-08-04 07:52:20 +0100352
Chris Wilsonb0decaf2016-08-04 07:52:44 +0100353 if (i915_vma_is_active(vma))
Chris Wilson894eeec2016-08-04 07:52:20 +0100354 stats->active += vma->node.size;
355 else
356 stats->inactive += vma->node.size;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100357 }
358
359 return 0;
360}
361
Chris Wilsonb0da1b72015-04-07 16:20:40 +0100362#define print_file_stats(m, name, stats) do { \
363 if (stats.count) \
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300364 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 +0100365 name, \
366 stats.count, \
367 stats.total, \
368 stats.active, \
369 stats.inactive, \
370 stats.global, \
371 stats.shared, \
372 stats.unbound); \
373} while (0)
Brad Volkin493018d2014-12-11 12:13:08 -0800374
375static void print_batch_pool_stats(struct seq_file *m,
376 struct drm_i915_private *dev_priv)
377{
378 struct drm_i915_gem_object *obj;
379 struct file_stats stats;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000380 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530381 enum intel_engine_id id;
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000382 int j;
Brad Volkin493018d2014-12-11 12:13:08 -0800383
384 memset(&stats, 0, sizeof(stats));
385
Akash Goel3b3f1652016-10-13 22:44:48 +0530386 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000387 for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) {
Chris Wilson8d9d5742015-04-07 16:20:38 +0100388 list_for_each_entry(obj,
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000389 &engine->batch_pool.cache_list[j],
Chris Wilson8d9d5742015-04-07 16:20:38 +0100390 batch_pool_link)
391 per_file_stats(0, obj, &stats);
392 }
Chris Wilson06fbca72015-04-07 16:20:36 +0100393 }
Brad Volkin493018d2014-12-11 12:13:08 -0800394
Chris Wilsonb0da1b72015-04-07 16:20:40 +0100395 print_file_stats(m, "[k]batch pool", stats);
Brad Volkin493018d2014-12-11 12:13:08 -0800396}
397
Chris Wilson15da9562016-05-24 14:53:43 +0100398static int per_file_ctx_stats(int id, void *ptr, void *data)
399{
400 struct i915_gem_context *ctx = ptr;
401 int n;
402
403 for (n = 0; n < ARRAY_SIZE(ctx->engine); n++) {
404 if (ctx->engine[n].state)
Chris Wilsonbf3783e2016-08-15 10:48:54 +0100405 per_file_stats(0, ctx->engine[n].state->obj, data);
Chris Wilsondca33ec2016-08-02 22:50:20 +0100406 if (ctx->engine[n].ring)
Chris Wilson57e88532016-08-15 10:48:57 +0100407 per_file_stats(0, ctx->engine[n].ring->vma->obj, data);
Chris Wilson15da9562016-05-24 14:53:43 +0100408 }
409
410 return 0;
411}
412
413static void print_context_stats(struct seq_file *m,
414 struct drm_i915_private *dev_priv)
415{
David Weinehall36cdd012016-08-22 13:59:31 +0300416 struct drm_device *dev = &dev_priv->drm;
Chris Wilson15da9562016-05-24 14:53:43 +0100417 struct file_stats stats;
418 struct drm_file *file;
419
420 memset(&stats, 0, sizeof(stats));
421
David Weinehall36cdd012016-08-22 13:59:31 +0300422 mutex_lock(&dev->struct_mutex);
Chris Wilson15da9562016-05-24 14:53:43 +0100423 if (dev_priv->kernel_context)
424 per_file_ctx_stats(0, dev_priv->kernel_context, &stats);
425
David Weinehall36cdd012016-08-22 13:59:31 +0300426 list_for_each_entry(file, &dev->filelist, lhead) {
Chris Wilson15da9562016-05-24 14:53:43 +0100427 struct drm_i915_file_private *fpriv = file->driver_priv;
428 idr_for_each(&fpriv->context_idr, per_file_ctx_stats, &stats);
429 }
David Weinehall36cdd012016-08-22 13:59:31 +0300430 mutex_unlock(&dev->struct_mutex);
Chris Wilson15da9562016-05-24 14:53:43 +0100431
432 print_file_stats(m, "[k]contexts", stats);
433}
434
David Weinehall36cdd012016-08-22 13:59:31 +0300435static int i915_gem_object_info(struct seq_file *m, void *data)
Chris Wilson73aa8082010-09-30 11:46:12 +0100436{
David Weinehall36cdd012016-08-22 13:59:31 +0300437 struct drm_i915_private *dev_priv = node_to_i915(m->private);
438 struct drm_device *dev = &dev_priv->drm;
Joonas Lahtinen72e96d62016-03-30 16:57:10 +0300439 struct i915_ggtt *ggtt = &dev_priv->ggtt;
Matthew Auld7393b7e2017-10-06 23:18:28 +0100440 u32 count, mapped_count, purgeable_count, dpy_count, huge_count;
441 u64 size, mapped_size, purgeable_size, dpy_size, huge_size;
Chris Wilson6299f992010-11-24 12:23:44 +0000442 struct drm_i915_gem_object *obj;
Matthew Auld7393b7e2017-10-06 23:18:28 +0100443 unsigned int page_sizes = 0;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100444 struct drm_file *file;
Matthew Auld7393b7e2017-10-06 23:18:28 +0100445 char buf[80];
Chris Wilson73aa8082010-09-30 11:46:12 +0100446 int ret;
447
448 ret = mutex_lock_interruptible(&dev->struct_mutex);
449 if (ret)
450 return ret;
451
Chris Wilson3ef7f222016-10-18 13:02:48 +0100452 seq_printf(m, "%u objects, %llu bytes\n",
Chris Wilson6299f992010-11-24 12:23:44 +0000453 dev_priv->mm.object_count,
454 dev_priv->mm.object_memory);
455
Chris Wilson1544c422016-08-15 13:18:16 +0100456 size = count = 0;
457 mapped_size = mapped_count = 0;
458 purgeable_size = purgeable_count = 0;
Matthew Auld7393b7e2017-10-06 23:18:28 +0100459 huge_size = huge_count = 0;
Chris Wilsonf2123812017-10-16 12:40:37 +0100460
461 spin_lock(&dev_priv->mm.obj_lock);
462 list_for_each_entry(obj, &dev_priv->mm.unbound_list, mm.link) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100463 size += obj->base.size;
464 ++count;
Chris Wilson6c085a72012-08-20 11:40:46 +0200465
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100466 if (obj->mm.madv == I915_MADV_DONTNEED) {
Chris Wilsonb7abb712012-08-20 11:33:30 +0200467 purgeable_size += obj->base.size;
468 ++purgeable_count;
469 }
Chris Wilson2bd160a2016-08-15 10:48:45 +0100470
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100471 if (obj->mm.mapping) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100472 mapped_count++;
473 mapped_size += obj->base.size;
Tvrtko Ursulinbe19b102016-04-15 11:34:53 +0100474 }
Matthew Auld7393b7e2017-10-06 23:18:28 +0100475
476 if (obj->mm.page_sizes.sg > I915_GTT_PAGE_SIZE) {
477 huge_count++;
478 huge_size += obj->base.size;
479 page_sizes |= obj->mm.page_sizes.sg;
480 }
Chris Wilson6299f992010-11-24 12:23:44 +0000481 }
Chris Wilson2bd160a2016-08-15 10:48:45 +0100482 seq_printf(m, "%u unbound objects, %llu bytes\n", count, size);
483
484 size = count = dpy_size = dpy_count = 0;
Chris Wilsonf2123812017-10-16 12:40:37 +0100485 list_for_each_entry(obj, &dev_priv->mm.bound_list, mm.link) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100486 size += obj->base.size;
487 ++count;
488
Chris Wilsonbd3d2252017-10-13 21:26:14 +0100489 if (obj->pin_global) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100490 dpy_size += obj->base.size;
491 ++dpy_count;
492 }
493
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100494 if (obj->mm.madv == I915_MADV_DONTNEED) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100495 purgeable_size += obj->base.size;
496 ++purgeable_count;
497 }
498
Chris Wilsona4f5ea62016-10-28 13:58:35 +0100499 if (obj->mm.mapping) {
Chris Wilson2bd160a2016-08-15 10:48:45 +0100500 mapped_count++;
501 mapped_size += obj->base.size;
502 }
Matthew Auld7393b7e2017-10-06 23:18:28 +0100503
504 if (obj->mm.page_sizes.sg > I915_GTT_PAGE_SIZE) {
505 huge_count++;
506 huge_size += obj->base.size;
507 page_sizes |= obj->mm.page_sizes.sg;
508 }
Chris Wilson2bd160a2016-08-15 10:48:45 +0100509 }
Chris Wilsonf2123812017-10-16 12:40:37 +0100510 spin_unlock(&dev_priv->mm.obj_lock);
511
Chris Wilson2bd160a2016-08-15 10:48:45 +0100512 seq_printf(m, "%u bound objects, %llu bytes\n",
513 count, size);
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300514 seq_printf(m, "%u purgeable objects, %llu bytes\n",
Chris Wilsonb7abb712012-08-20 11:33:30 +0200515 purgeable_count, purgeable_size);
Chris Wilson2bd160a2016-08-15 10:48:45 +0100516 seq_printf(m, "%u mapped objects, %llu bytes\n",
517 mapped_count, mapped_size);
Matthew Auld7393b7e2017-10-06 23:18:28 +0100518 seq_printf(m, "%u huge-paged objects (%s) %llu bytes\n",
519 huge_count,
520 stringify_page_sizes(page_sizes, buf, sizeof(buf)),
521 huge_size);
Chris Wilsonbd3d2252017-10-13 21:26:14 +0100522 seq_printf(m, "%u display objects (globally pinned), %llu bytes\n",
Chris Wilson2bd160a2016-08-15 10:48:45 +0100523 dpy_count, dpy_size);
Chris Wilson6299f992010-11-24 12:23:44 +0000524
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300525 seq_printf(m, "%llu [%llu] gtt total\n",
Chris Wilson381b9432017-02-15 08:43:54 +0000526 ggtt->base.total, ggtt->mappable_end);
Matthew Auld7393b7e2017-10-06 23:18:28 +0100527 seq_printf(m, "Supported page sizes: %s\n",
528 stringify_page_sizes(INTEL_INFO(dev_priv)->page_sizes,
529 buf, sizeof(buf)));
Chris Wilson73aa8082010-09-30 11:46:12 +0100530
Damien Lespiau267f0c92013-06-24 22:59:48 +0100531 seq_putc(m, '\n');
Brad Volkin493018d2014-12-11 12:13:08 -0800532 print_batch_pool_stats(m, dev_priv);
Daniel Vetter1d2ac402016-04-26 19:29:41 +0200533 mutex_unlock(&dev->struct_mutex);
534
535 mutex_lock(&dev->filelist_mutex);
Chris Wilson15da9562016-05-24 14:53:43 +0100536 print_context_stats(m, dev_priv);
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100537 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
538 struct file_stats stats;
Chris Wilsonc84455b2016-08-15 10:49:08 +0100539 struct drm_i915_file_private *file_priv = file->driver_priv;
540 struct drm_i915_gem_request *request;
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900541 struct task_struct *task;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100542
Chris Wilson0caf81b2017-06-17 12:57:44 +0100543 mutex_lock(&dev->struct_mutex);
544
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100545 memset(&stats, 0, sizeof(stats));
Chris Wilson6313c202014-03-19 13:45:45 +0000546 stats.file_priv = file->driver_priv;
Chris Wilson5b5ffff2014-06-17 09:56:24 +0100547 spin_lock(&file->table_lock);
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100548 idr_for_each(&file->object_idr, per_file_stats, &stats);
Chris Wilson5b5ffff2014-06-17 09:56:24 +0100549 spin_unlock(&file->table_lock);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900550 /*
551 * Although we have a valid reference on file->pid, that does
552 * not guarantee that the task_struct who called get_pid() is
553 * still alive (e.g. get_pid(current) => fork() => exit()).
554 * Therefore, we need to protect this ->comm access using RCU.
555 */
Chris Wilsonc84455b2016-08-15 10:49:08 +0100556 request = list_first_entry_or_null(&file_priv->mm.request_list,
557 struct drm_i915_gem_request,
Chris Wilsonc8659ef2017-03-02 12:25:25 +0000558 client_link);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900559 rcu_read_lock();
Chris Wilsonc84455b2016-08-15 10:49:08 +0100560 task = pid_task(request && request->ctx->pid ?
561 request->ctx->pid : file->pid,
562 PIDTYPE_PID);
Brad Volkin493018d2014-12-11 12:13:08 -0800563 print_file_stats(m, task ? task->comm : "<unknown>", stats);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900564 rcu_read_unlock();
Chris Wilson0caf81b2017-06-17 12:57:44 +0100565
Chris Wilsonc84455b2016-08-15 10:49:08 +0100566 mutex_unlock(&dev->struct_mutex);
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100567 }
Daniel Vetter1d2ac402016-04-26 19:29:41 +0200568 mutex_unlock(&dev->filelist_mutex);
Chris Wilson73aa8082010-09-30 11:46:12 +0100569
570 return 0;
571}
572
Damien Lespiauaee56cf2013-06-24 22:59:49 +0100573static int i915_gem_gtt_info(struct seq_file *m, void *data)
Chris Wilson08c18322011-01-10 00:00:24 +0000574{
Damien Lespiau9f25d002014-05-13 15:30:28 +0100575 struct drm_info_node *node = m->private;
David Weinehall36cdd012016-08-22 13:59:31 +0300576 struct drm_i915_private *dev_priv = node_to_i915(node);
577 struct drm_device *dev = &dev_priv->drm;
Chris Wilsonf2123812017-10-16 12:40:37 +0100578 struct drm_i915_gem_object **objects;
Chris Wilson08c18322011-01-10 00:00:24 +0000579 struct drm_i915_gem_object *obj;
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300580 u64 total_obj_size, total_gtt_size;
Chris Wilsonf2123812017-10-16 12:40:37 +0100581 unsigned long nobject, n;
Chris Wilson08c18322011-01-10 00:00:24 +0000582 int count, ret;
583
Chris Wilsonf2123812017-10-16 12:40:37 +0100584 nobject = READ_ONCE(dev_priv->mm.object_count);
585 objects = kvmalloc_array(nobject, sizeof(*objects), GFP_KERNEL);
586 if (!objects)
587 return -ENOMEM;
588
Chris Wilson08c18322011-01-10 00:00:24 +0000589 ret = mutex_lock_interruptible(&dev->struct_mutex);
590 if (ret)
591 return ret;
592
Chris Wilsonf2123812017-10-16 12:40:37 +0100593 count = 0;
594 spin_lock(&dev_priv->mm.obj_lock);
595 list_for_each_entry(obj, &dev_priv->mm.bound_list, mm.link) {
596 objects[count++] = obj;
597 if (count == nobject)
598 break;
599 }
600 spin_unlock(&dev_priv->mm.obj_lock);
601
602 total_obj_size = total_gtt_size = 0;
603 for (n = 0; n < count; n++) {
604 obj = objects[n];
605
Damien Lespiau267f0c92013-06-24 22:59:48 +0100606 seq_puts(m, " ");
Chris Wilson08c18322011-01-10 00:00:24 +0000607 describe_obj(m, obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +0100608 seq_putc(m, '\n');
Chris Wilson08c18322011-01-10 00:00:24 +0000609 total_obj_size += obj->base.size;
Tvrtko Ursulinca1543b2015-07-01 11:51:10 +0100610 total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
Chris Wilson08c18322011-01-10 00:00:24 +0000611 }
612
613 mutex_unlock(&dev->struct_mutex);
614
Mika Kuoppalac44ef602015-06-25 18:35:05 +0300615 seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n",
Chris Wilson08c18322011-01-10 00:00:24 +0000616 count, total_obj_size, total_gtt_size);
Chris Wilsonf2123812017-10-16 12:40:37 +0100617 kvfree(objects);
Chris Wilson08c18322011-01-10 00:00:24 +0000618
619 return 0;
620}
621
Brad Volkin493018d2014-12-11 12:13:08 -0800622static int i915_gem_batch_pool_info(struct seq_file *m, void *data)
623{
David Weinehall36cdd012016-08-22 13:59:31 +0300624 struct drm_i915_private *dev_priv = node_to_i915(m->private);
625 struct drm_device *dev = &dev_priv->drm;
Brad Volkin493018d2014-12-11 12:13:08 -0800626 struct drm_i915_gem_object *obj;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000627 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530628 enum intel_engine_id id;
Chris Wilson8d9d5742015-04-07 16:20:38 +0100629 int total = 0;
Dave Gordonb4ac5af2016-03-24 11:20:38 +0000630 int ret, j;
Brad Volkin493018d2014-12-11 12:13:08 -0800631
632 ret = mutex_lock_interruptible(&dev->struct_mutex);
633 if (ret)
634 return ret;
635
Akash Goel3b3f1652016-10-13 22:44:48 +0530636 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000637 for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) {
Chris Wilson8d9d5742015-04-07 16:20:38 +0100638 int count;
639
640 count = 0;
641 list_for_each_entry(obj,
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000642 &engine->batch_pool.cache_list[j],
Chris Wilson8d9d5742015-04-07 16:20:38 +0100643 batch_pool_link)
644 count++;
645 seq_printf(m, "%s cache[%d]: %d objects\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000646 engine->name, j, count);
Chris Wilson8d9d5742015-04-07 16:20:38 +0100647
648 list_for_each_entry(obj,
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000649 &engine->batch_pool.cache_list[j],
Chris Wilson8d9d5742015-04-07 16:20:38 +0100650 batch_pool_link) {
651 seq_puts(m, " ");
652 describe_obj(m, obj);
653 seq_putc(m, '\n');
654 }
655
656 total += count;
Chris Wilson06fbca72015-04-07 16:20:36 +0100657 }
Brad Volkin493018d2014-12-11 12:13:08 -0800658 }
659
Chris Wilson8d9d5742015-04-07 16:20:38 +0100660 seq_printf(m, "total: %d\n", total);
Brad Volkin493018d2014-12-11 12:13:08 -0800661
662 mutex_unlock(&dev->struct_mutex);
663
664 return 0;
665}
666
Chris Wilsonb2223492010-10-27 15:27:33 +0100667static void i915_ring_seqno_info(struct seq_file *m,
Tvrtko Ursulin0bc40be2016-03-16 11:00:37 +0000668 struct intel_engine_cs *engine)
Chris Wilsonb2223492010-10-27 15:27:33 +0100669{
Chris Wilson688e6c72016-07-01 17:23:15 +0100670 struct intel_breadcrumbs *b = &engine->breadcrumbs;
671 struct rb_node *rb;
672
Chris Wilson12471ba2016-04-09 10:57:55 +0100673 seq_printf(m, "Current sequence (%s): %x\n",
Chris Wilson1b7744e2016-07-01 17:23:17 +0100674 engine->name, intel_engine_get_seqno(engine));
Chris Wilson688e6c72016-07-01 17:23:15 +0100675
Chris Wilson61d3dc72017-03-03 19:08:24 +0000676 spin_lock_irq(&b->rb_lock);
Chris Wilson688e6c72016-07-01 17:23:15 +0100677 for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) {
Geliang Tangf802cf72016-12-19 22:43:49 +0800678 struct intel_wait *w = rb_entry(rb, typeof(*w), node);
Chris Wilson688e6c72016-07-01 17:23:15 +0100679
680 seq_printf(m, "Waiting (%s): %s [%d] on %x\n",
681 engine->name, w->tsk->comm, w->tsk->pid, w->seqno);
682 }
Chris Wilson61d3dc72017-03-03 19:08:24 +0000683 spin_unlock_irq(&b->rb_lock);
Chris Wilsonb2223492010-10-27 15:27:33 +0100684}
685
Ben Gamari20172632009-02-17 20:08:50 -0500686static int i915_gem_seqno_info(struct seq_file *m, void *data)
687{
David Weinehall36cdd012016-08-22 13:59:31 +0300688 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000689 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530690 enum intel_engine_id id;
Ben Gamari20172632009-02-17 20:08:50 -0500691
Akash Goel3b3f1652016-10-13 22:44:48 +0530692 for_each_engine(engine, dev_priv, id)
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000693 i915_ring_seqno_info(m, engine);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100694
Ben Gamari20172632009-02-17 20:08:50 -0500695 return 0;
696}
697
698
699static int i915_interrupt_info(struct seq_file *m, void *data)
700{
David Weinehall36cdd012016-08-22 13:59:31 +0300701 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000702 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +0530703 enum intel_engine_id id;
Chris Wilson4bb05042016-09-03 07:53:43 +0100704 int i, pipe;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100705
Paulo Zanonic8c8fb32013-11-27 18:21:54 -0200706 intel_runtime_pm_get(dev_priv);
Ben Gamari20172632009-02-17 20:08:50 -0500707
David Weinehall36cdd012016-08-22 13:59:31 +0300708 if (IS_CHERRYVIEW(dev_priv)) {
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300709 seq_printf(m, "Master Interrupt Control:\t%08x\n",
710 I915_READ(GEN8_MASTER_IRQ));
711
712 seq_printf(m, "Display IER:\t%08x\n",
713 I915_READ(VLV_IER));
714 seq_printf(m, "Display IIR:\t%08x\n",
715 I915_READ(VLV_IIR));
716 seq_printf(m, "Display IIR_RW:\t%08x\n",
717 I915_READ(VLV_IIR_RW));
718 seq_printf(m, "Display IMR:\t%08x\n",
719 I915_READ(VLV_IMR));
Chris Wilson9c870d02016-10-24 13:42:15 +0100720 for_each_pipe(dev_priv, pipe) {
721 enum intel_display_power_domain power_domain;
722
723 power_domain = POWER_DOMAIN_PIPE(pipe);
724 if (!intel_display_power_get_if_enabled(dev_priv,
725 power_domain)) {
726 seq_printf(m, "Pipe %c power disabled\n",
727 pipe_name(pipe));
728 continue;
729 }
730
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300731 seq_printf(m, "Pipe %c stat:\t%08x\n",
732 pipe_name(pipe),
733 I915_READ(PIPESTAT(pipe)));
734
Chris Wilson9c870d02016-10-24 13:42:15 +0100735 intel_display_power_put(dev_priv, power_domain);
736 }
737
738 intel_display_power_get(dev_priv, POWER_DOMAIN_INIT);
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300739 seq_printf(m, "Port hotplug:\t%08x\n",
740 I915_READ(PORT_HOTPLUG_EN));
741 seq_printf(m, "DPFLIPSTAT:\t%08x\n",
742 I915_READ(VLV_DPFLIPSTAT));
743 seq_printf(m, "DPINVGTT:\t%08x\n",
744 I915_READ(DPINVGTT));
Chris Wilson9c870d02016-10-24 13:42:15 +0100745 intel_display_power_put(dev_priv, POWER_DOMAIN_INIT);
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300746
747 for (i = 0; i < 4; i++) {
748 seq_printf(m, "GT Interrupt IMR %d:\t%08x\n",
749 i, I915_READ(GEN8_GT_IMR(i)));
750 seq_printf(m, "GT Interrupt IIR %d:\t%08x\n",
751 i, I915_READ(GEN8_GT_IIR(i)));
752 seq_printf(m, "GT Interrupt IER %d:\t%08x\n",
753 i, I915_READ(GEN8_GT_IER(i)));
754 }
755
756 seq_printf(m, "PCU interrupt mask:\t%08x\n",
757 I915_READ(GEN8_PCU_IMR));
758 seq_printf(m, "PCU interrupt identity:\t%08x\n",
759 I915_READ(GEN8_PCU_IIR));
760 seq_printf(m, "PCU interrupt enable:\t%08x\n",
761 I915_READ(GEN8_PCU_IER));
David Weinehall36cdd012016-08-22 13:59:31 +0300762 } else if (INTEL_GEN(dev_priv) >= 8) {
Ben Widawskya123f152013-11-02 21:07:10 -0700763 seq_printf(m, "Master Interrupt Control:\t%08x\n",
764 I915_READ(GEN8_MASTER_IRQ));
765
766 for (i = 0; i < 4; i++) {
767 seq_printf(m, "GT Interrupt IMR %d:\t%08x\n",
768 i, I915_READ(GEN8_GT_IMR(i)));
769 seq_printf(m, "GT Interrupt IIR %d:\t%08x\n",
770 i, I915_READ(GEN8_GT_IIR(i)));
771 seq_printf(m, "GT Interrupt IER %d:\t%08x\n",
772 i, I915_READ(GEN8_GT_IER(i)));
773 }
774
Damien Lespiau055e3932014-08-18 13:49:10 +0100775 for_each_pipe(dev_priv, pipe) {
Imre Deake1296492016-02-12 18:55:17 +0200776 enum intel_display_power_domain power_domain;
777
778 power_domain = POWER_DOMAIN_PIPE(pipe);
779 if (!intel_display_power_get_if_enabled(dev_priv,
780 power_domain)) {
Paulo Zanoni22c59962014-08-08 17:45:32 -0300781 seq_printf(m, "Pipe %c power disabled\n",
782 pipe_name(pipe));
783 continue;
784 }
Ben Widawskya123f152013-11-02 21:07:10 -0700785 seq_printf(m, "Pipe %c IMR:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000786 pipe_name(pipe),
787 I915_READ(GEN8_DE_PIPE_IMR(pipe)));
Ben Widawskya123f152013-11-02 21:07:10 -0700788 seq_printf(m, "Pipe %c IIR:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000789 pipe_name(pipe),
790 I915_READ(GEN8_DE_PIPE_IIR(pipe)));
Ben Widawskya123f152013-11-02 21:07:10 -0700791 seq_printf(m, "Pipe %c IER:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000792 pipe_name(pipe),
793 I915_READ(GEN8_DE_PIPE_IER(pipe)));
Imre Deake1296492016-02-12 18:55:17 +0200794
795 intel_display_power_put(dev_priv, power_domain);
Ben Widawskya123f152013-11-02 21:07:10 -0700796 }
797
798 seq_printf(m, "Display Engine port interrupt mask:\t%08x\n",
799 I915_READ(GEN8_DE_PORT_IMR));
800 seq_printf(m, "Display Engine port interrupt identity:\t%08x\n",
801 I915_READ(GEN8_DE_PORT_IIR));
802 seq_printf(m, "Display Engine port interrupt enable:\t%08x\n",
803 I915_READ(GEN8_DE_PORT_IER));
804
805 seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n",
806 I915_READ(GEN8_DE_MISC_IMR));
807 seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n",
808 I915_READ(GEN8_DE_MISC_IIR));
809 seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n",
810 I915_READ(GEN8_DE_MISC_IER));
811
812 seq_printf(m, "PCU interrupt mask:\t%08x\n",
813 I915_READ(GEN8_PCU_IMR));
814 seq_printf(m, "PCU interrupt identity:\t%08x\n",
815 I915_READ(GEN8_PCU_IIR));
816 seq_printf(m, "PCU interrupt enable:\t%08x\n",
817 I915_READ(GEN8_PCU_IER));
David Weinehall36cdd012016-08-22 13:59:31 +0300818 } else if (IS_VALLEYVIEW(dev_priv)) {
Jesse Barnes7e231dbe2012-03-28 13:39:38 -0700819 seq_printf(m, "Display IER:\t%08x\n",
820 I915_READ(VLV_IER));
821 seq_printf(m, "Display IIR:\t%08x\n",
822 I915_READ(VLV_IIR));
823 seq_printf(m, "Display IIR_RW:\t%08x\n",
824 I915_READ(VLV_IIR_RW));
825 seq_printf(m, "Display IMR:\t%08x\n",
826 I915_READ(VLV_IMR));
Chris Wilson4f4631a2017-02-10 13:36:32 +0000827 for_each_pipe(dev_priv, pipe) {
828 enum intel_display_power_domain power_domain;
829
830 power_domain = POWER_DOMAIN_PIPE(pipe);
831 if (!intel_display_power_get_if_enabled(dev_priv,
832 power_domain)) {
833 seq_printf(m, "Pipe %c power disabled\n",
834 pipe_name(pipe));
835 continue;
836 }
837
Jesse Barnes7e231dbe2012-03-28 13:39:38 -0700838 seq_printf(m, "Pipe %c stat:\t%08x\n",
839 pipe_name(pipe),
840 I915_READ(PIPESTAT(pipe)));
Chris Wilson4f4631a2017-02-10 13:36:32 +0000841 intel_display_power_put(dev_priv, power_domain);
842 }
Jesse Barnes7e231dbe2012-03-28 13:39:38 -0700843
844 seq_printf(m, "Master IER:\t%08x\n",
845 I915_READ(VLV_MASTER_IER));
846
847 seq_printf(m, "Render IER:\t%08x\n",
848 I915_READ(GTIER));
849 seq_printf(m, "Render IIR:\t%08x\n",
850 I915_READ(GTIIR));
851 seq_printf(m, "Render IMR:\t%08x\n",
852 I915_READ(GTIMR));
853
854 seq_printf(m, "PM IER:\t\t%08x\n",
855 I915_READ(GEN6_PMIER));
856 seq_printf(m, "PM IIR:\t\t%08x\n",
857 I915_READ(GEN6_PMIIR));
858 seq_printf(m, "PM IMR:\t\t%08x\n",
859 I915_READ(GEN6_PMIMR));
860
861 seq_printf(m, "Port hotplug:\t%08x\n",
862 I915_READ(PORT_HOTPLUG_EN));
863 seq_printf(m, "DPFLIPSTAT:\t%08x\n",
864 I915_READ(VLV_DPFLIPSTAT));
865 seq_printf(m, "DPINVGTT:\t%08x\n",
866 I915_READ(DPINVGTT));
867
David Weinehall36cdd012016-08-22 13:59:31 +0300868 } else if (!HAS_PCH_SPLIT(dev_priv)) {
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800869 seq_printf(m, "Interrupt enable: %08x\n",
870 I915_READ(IER));
871 seq_printf(m, "Interrupt identity: %08x\n",
872 I915_READ(IIR));
873 seq_printf(m, "Interrupt mask: %08x\n",
874 I915_READ(IMR));
Damien Lespiau055e3932014-08-18 13:49:10 +0100875 for_each_pipe(dev_priv, pipe)
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800876 seq_printf(m, "Pipe %c stat: %08x\n",
877 pipe_name(pipe),
878 I915_READ(PIPESTAT(pipe)));
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800879 } else {
880 seq_printf(m, "North Display Interrupt enable: %08x\n",
881 I915_READ(DEIER));
882 seq_printf(m, "North Display Interrupt identity: %08x\n",
883 I915_READ(DEIIR));
884 seq_printf(m, "North Display Interrupt mask: %08x\n",
885 I915_READ(DEIMR));
886 seq_printf(m, "South Display Interrupt enable: %08x\n",
887 I915_READ(SDEIER));
888 seq_printf(m, "South Display Interrupt identity: %08x\n",
889 I915_READ(SDEIIR));
890 seq_printf(m, "South Display Interrupt mask: %08x\n",
891 I915_READ(SDEIMR));
892 seq_printf(m, "Graphics Interrupt enable: %08x\n",
893 I915_READ(GTIER));
894 seq_printf(m, "Graphics Interrupt identity: %08x\n",
895 I915_READ(GTIIR));
896 seq_printf(m, "Graphics Interrupt mask: %08x\n",
897 I915_READ(GTIMR));
898 }
Akash Goel3b3f1652016-10-13 22:44:48 +0530899 for_each_engine(engine, dev_priv, id) {
David Weinehall36cdd012016-08-22 13:59:31 +0300900 if (INTEL_GEN(dev_priv) >= 6) {
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100901 seq_printf(m,
902 "Graphics Interrupt mask (%s): %08x\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000903 engine->name, I915_READ_IMR(engine));
Chris Wilson9862e602011-01-04 22:22:17 +0000904 }
Tvrtko Ursuline2f80392016-03-16 11:00:36 +0000905 i915_ring_seqno_info(m, engine);
Chris Wilson9862e602011-01-04 22:22:17 +0000906 }
Paulo Zanonic8c8fb32013-11-27 18:21:54 -0200907 intel_runtime_pm_put(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100908
Ben Gamari20172632009-02-17 20:08:50 -0500909 return 0;
910}
911
Chris Wilsona6172a82009-02-11 14:26:38 +0000912static int i915_gem_fence_regs_info(struct seq_file *m, void *data)
913{
David Weinehall36cdd012016-08-22 13:59:31 +0300914 struct drm_i915_private *dev_priv = node_to_i915(m->private);
915 struct drm_device *dev = &dev_priv->drm;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100916 int i, ret;
917
918 ret = mutex_lock_interruptible(&dev->struct_mutex);
919 if (ret)
920 return ret;
Chris Wilsona6172a82009-02-11 14:26:38 +0000921
Chris Wilsona6172a82009-02-11 14:26:38 +0000922 seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs);
923 for (i = 0; i < dev_priv->num_fence_regs; i++) {
Chris Wilson49ef5292016-08-18 17:17:00 +0100924 struct i915_vma *vma = dev_priv->fence_regs[i].vma;
Chris Wilsona6172a82009-02-11 14:26:38 +0000925
Chris Wilson6c085a72012-08-20 11:40:46 +0200926 seq_printf(m, "Fence %d, pin count = %d, object = ",
927 i, dev_priv->fence_regs[i].pin_count);
Chris Wilson49ef5292016-08-18 17:17:00 +0100928 if (!vma)
Damien Lespiau267f0c92013-06-24 22:59:48 +0100929 seq_puts(m, "unused");
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100930 else
Chris Wilson49ef5292016-08-18 17:17:00 +0100931 describe_obj(m, vma->obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +0100932 seq_putc(m, '\n');
Chris Wilsona6172a82009-02-11 14:26:38 +0000933 }
934
Chris Wilson05394f32010-11-08 19:18:58 +0000935 mutex_unlock(&dev->struct_mutex);
Chris Wilsona6172a82009-02-11 14:26:38 +0000936 return 0;
937}
938
Chris Wilson98a2f412016-10-12 10:05:18 +0100939#if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR)
Chris Wilson5a4c6f12017-02-14 16:46:11 +0000940static ssize_t gpu_state_read(struct file *file, char __user *ubuf,
941 size_t count, loff_t *pos)
942{
943 struct i915_gpu_state *error = file->private_data;
944 struct drm_i915_error_state_buf str;
945 ssize_t ret;
946 loff_t tmp;
947
948 if (!error)
949 return 0;
950
951 ret = i915_error_state_buf_init(&str, error->i915, count, *pos);
952 if (ret)
953 return ret;
954
955 ret = i915_error_state_to_str(&str, error);
956 if (ret)
957 goto out;
958
959 tmp = 0;
960 ret = simple_read_from_buffer(ubuf, count, &tmp, str.buf, str.bytes);
961 if (ret < 0)
962 goto out;
963
964 *pos = str.start + ret;
965out:
966 i915_error_state_buf_release(&str);
967 return ret;
968}
969
970static int gpu_state_release(struct inode *inode, struct file *file)
971{
972 i915_gpu_state_put(file->private_data);
973 return 0;
974}
975
976static int i915_gpu_info_open(struct inode *inode, struct file *file)
977{
Chris Wilson090e5fe2017-03-28 14:14:07 +0100978 struct drm_i915_private *i915 = inode->i_private;
Chris Wilson5a4c6f12017-02-14 16:46:11 +0000979 struct i915_gpu_state *gpu;
980
Chris Wilson090e5fe2017-03-28 14:14:07 +0100981 intel_runtime_pm_get(i915);
982 gpu = i915_capture_gpu_state(i915);
983 intel_runtime_pm_put(i915);
Chris Wilson5a4c6f12017-02-14 16:46:11 +0000984 if (!gpu)
985 return -ENOMEM;
986
987 file->private_data = gpu;
988 return 0;
989}
990
991static const struct file_operations i915_gpu_info_fops = {
992 .owner = THIS_MODULE,
993 .open = i915_gpu_info_open,
994 .read = gpu_state_read,
995 .llseek = default_llseek,
996 .release = gpu_state_release,
997};
Chris Wilson98a2f412016-10-12 10:05:18 +0100998
Daniel Vetterd5442302012-04-27 15:17:40 +0200999static ssize_t
1000i915_error_state_write(struct file *filp,
1001 const char __user *ubuf,
1002 size_t cnt,
1003 loff_t *ppos)
1004{
Chris Wilson5a4c6f12017-02-14 16:46:11 +00001005 struct i915_gpu_state *error = filp->private_data;
1006
1007 if (!error)
1008 return 0;
Daniel Vetterd5442302012-04-27 15:17:40 +02001009
1010 DRM_DEBUG_DRIVER("Resetting error state\n");
Chris Wilson5a4c6f12017-02-14 16:46:11 +00001011 i915_reset_error_state(error->i915);
Daniel Vetterd5442302012-04-27 15:17:40 +02001012
1013 return cnt;
1014}
1015
1016static int i915_error_state_open(struct inode *inode, struct file *file)
1017{
Chris Wilson5a4c6f12017-02-14 16:46:11 +00001018 file->private_data = i915_first_error_state(inode->i_private);
Mika Kuoppalaedc3d882013-05-23 13:55:35 +03001019 return 0;
Daniel Vetterd5442302012-04-27 15:17:40 +02001020}
1021
Daniel Vetterd5442302012-04-27 15:17:40 +02001022static const struct file_operations i915_error_state_fops = {
1023 .owner = THIS_MODULE,
1024 .open = i915_error_state_open,
Chris Wilson5a4c6f12017-02-14 16:46:11 +00001025 .read = gpu_state_read,
Daniel Vetterd5442302012-04-27 15:17:40 +02001026 .write = i915_error_state_write,
1027 .llseek = default_llseek,
Chris Wilson5a4c6f12017-02-14 16:46:11 +00001028 .release = gpu_state_release,
Daniel Vetterd5442302012-04-27 15:17:40 +02001029};
Chris Wilson98a2f412016-10-12 10:05:18 +01001030#endif
1031
Kees Cook647416f2013-03-10 14:10:06 -07001032static int
Kees Cook647416f2013-03-10 14:10:06 -07001033i915_next_seqno_set(void *data, u64 val)
Mika Kuoppala40633212012-12-04 15:12:00 +02001034{
David Weinehall36cdd012016-08-22 13:59:31 +03001035 struct drm_i915_private *dev_priv = data;
1036 struct drm_device *dev = &dev_priv->drm;
Mika Kuoppala40633212012-12-04 15:12:00 +02001037 int ret;
1038
Mika Kuoppala40633212012-12-04 15:12:00 +02001039 ret = mutex_lock_interruptible(&dev->struct_mutex);
1040 if (ret)
1041 return ret;
1042
Chris Wilson73cb9702016-10-28 13:58:46 +01001043 ret = i915_gem_set_global_seqno(dev, val);
Mika Kuoppala40633212012-12-04 15:12:00 +02001044 mutex_unlock(&dev->struct_mutex);
1045
Kees Cook647416f2013-03-10 14:10:06 -07001046 return ret;
Mika Kuoppala40633212012-12-04 15:12:00 +02001047}
1048
Kees Cook647416f2013-03-10 14:10:06 -07001049DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops,
Chris Wilson9b6586a2017-02-23 07:44:08 +00001050 NULL, i915_next_seqno_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03001051 "0x%llx\n");
Mika Kuoppala40633212012-12-04 15:12:00 +02001052
Deepak Sadb4bd12014-03-31 11:30:02 +05301053static int i915_frequency_info(struct seq_file *m, void *unused)
Jesse Barnesf97108d2010-01-29 11:27:07 -08001054{
David Weinehall36cdd012016-08-22 13:59:31 +03001055 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01001056 struct intel_rps *rps = &dev_priv->gt_pm.rps;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001057 int ret = 0;
1058
1059 intel_runtime_pm_get(dev_priv);
Jesse Barnesf97108d2010-01-29 11:27:07 -08001060
David Weinehall36cdd012016-08-22 13:59:31 +03001061 if (IS_GEN5(dev_priv)) {
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001062 u16 rgvswctl = I915_READ16(MEMSWCTL);
1063 u16 rgvstat = I915_READ16(MEMSTAT_ILK);
1064
1065 seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf);
1066 seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f);
1067 seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >>
1068 MEMSTAT_VID_SHIFT);
1069 seq_printf(m, "Current P-state: %d\n",
1070 (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT);
David Weinehall36cdd012016-08-22 13:59:31 +03001071 } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
Sagar Arun Kamble0d6fc922017-10-10 22:30:02 +01001072 u32 rpmodectl, freq_sts;
Wayne Boyer666a4532015-12-09 12:29:35 -08001073
Sagar Arun Kamble9f817502017-10-10 22:30:05 +01001074 mutex_lock(&dev_priv->pcu_lock);
Sagar Arun Kamble0d6fc922017-10-10 22:30:02 +01001075
1076 rpmodectl = I915_READ(GEN6_RP_CONTROL);
1077 seq_printf(m, "Video Turbo Mode: %s\n",
1078 yesno(rpmodectl & GEN6_RP_MEDIA_TURBO));
1079 seq_printf(m, "HW control enabled: %s\n",
1080 yesno(rpmodectl & GEN6_RP_ENABLE));
1081 seq_printf(m, "SW control enabled: %s\n",
1082 yesno((rpmodectl & GEN6_RP_MEDIA_MODE_MASK) ==
1083 GEN6_RP_MEDIA_SW_MODE));
1084
Wayne Boyer666a4532015-12-09 12:29:35 -08001085 freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
1086 seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts);
1087 seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq);
1088
1089 seq_printf(m, "actual GPU freq: %d MHz\n",
1090 intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff));
1091
1092 seq_printf(m, "current GPU freq: %d MHz\n",
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01001093 intel_gpu_freq(dev_priv, rps->cur_freq));
Wayne Boyer666a4532015-12-09 12:29:35 -08001094
1095 seq_printf(m, "max GPU freq: %d MHz\n",
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01001096 intel_gpu_freq(dev_priv, rps->max_freq));
Wayne Boyer666a4532015-12-09 12:29:35 -08001097
1098 seq_printf(m, "min GPU freq: %d MHz\n",
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01001099 intel_gpu_freq(dev_priv, rps->min_freq));
Wayne Boyer666a4532015-12-09 12:29:35 -08001100
1101 seq_printf(m, "idle GPU freq: %d MHz\n",
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01001102 intel_gpu_freq(dev_priv, rps->idle_freq));
Wayne Boyer666a4532015-12-09 12:29:35 -08001103
1104 seq_printf(m,
1105 "efficient (RPe) frequency: %d MHz\n",
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01001106 intel_gpu_freq(dev_priv, rps->efficient_freq));
Sagar Arun Kamble9f817502017-10-10 22:30:05 +01001107 mutex_unlock(&dev_priv->pcu_lock);
David Weinehall36cdd012016-08-22 13:59:31 +03001108 } else if (INTEL_GEN(dev_priv) >= 6) {
Bob Paauwe35040562015-06-25 14:54:07 -07001109 u32 rp_state_limits;
1110 u32 gt_perf_status;
1111 u32 rp_state_cap;
Chris Wilson0d8f9492014-03-27 09:06:14 +00001112 u32 rpmodectl, rpinclimit, rpdeclimit;
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001113 u32 rpstat, cagf, reqf;
Jesse Barnesccab5c82011-01-18 15:49:25 -08001114 u32 rpupei, rpcurup, rpprevup;
1115 u32 rpdownei, rpcurdown, rpprevdown;
Paulo Zanoni9dd3c602014-08-01 18:14:48 -03001116 u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask;
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001117 int max_freq;
1118
Bob Paauwe35040562015-06-25 14:54:07 -07001119 rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS);
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02001120 if (IS_GEN9_LP(dev_priv)) {
Bob Paauwe35040562015-06-25 14:54:07 -07001121 rp_state_cap = I915_READ(BXT_RP_STATE_CAP);
1122 gt_perf_status = I915_READ(BXT_GT_PERF_STATUS);
1123 } else {
1124 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
1125 gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS);
1126 }
1127
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001128 /* RPSTAT1 is in the GT power well */
Mika Kuoppala59bad942015-01-16 11:34:40 +02001129 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001130
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001131 reqf = I915_READ(GEN6_RPNSWREQ);
Rodrigo Vivi35ceabf2017-07-06 13:41:13 -07001132 if (INTEL_GEN(dev_priv) >= 9)
Akash Goel60260a52015-03-06 11:07:21 +05301133 reqf >>= 23;
1134 else {
1135 reqf &= ~GEN6_TURBO_DISABLE;
David Weinehall36cdd012016-08-22 13:59:31 +03001136 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
Akash Goel60260a52015-03-06 11:07:21 +05301137 reqf >>= 24;
1138 else
1139 reqf >>= 25;
1140 }
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001141 reqf = intel_gpu_freq(dev_priv, reqf);
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001142
Chris Wilson0d8f9492014-03-27 09:06:14 +00001143 rpmodectl = I915_READ(GEN6_RP_CONTROL);
1144 rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD);
1145 rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD);
1146
Jesse Barnesccab5c82011-01-18 15:49:25 -08001147 rpstat = I915_READ(GEN6_RPSTAT1);
Akash Goeld6cda9c2016-04-23 00:05:46 +05301148 rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK;
1149 rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK;
1150 rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK;
1151 rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK;
1152 rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK;
1153 rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK;
Rodrigo Vivi35ceabf2017-07-06 13:41:13 -07001154 if (INTEL_GEN(dev_priv) >= 9)
Akash Goel60260a52015-03-06 11:07:21 +05301155 cagf = (rpstat & GEN9_CAGF_MASK) >> GEN9_CAGF_SHIFT;
David Weinehall36cdd012016-08-22 13:59:31 +03001156 else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
Ben Widawskyf82855d2013-01-29 12:00:15 -08001157 cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT;
1158 else
1159 cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT;
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001160 cagf = intel_gpu_freq(dev_priv, cagf);
Jesse Barnesccab5c82011-01-18 15:49:25 -08001161
Mika Kuoppala59bad942015-01-16 11:34:40 +02001162 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
Ben Widawskyd1ebd8162011-04-25 20:11:50 +01001163
David Weinehall36cdd012016-08-22 13:59:31 +03001164 if (IS_GEN6(dev_priv) || IS_GEN7(dev_priv)) {
Paulo Zanoni9dd3c602014-08-01 18:14:48 -03001165 pm_ier = I915_READ(GEN6_PMIER);
1166 pm_imr = I915_READ(GEN6_PMIMR);
1167 pm_isr = I915_READ(GEN6_PMISR);
1168 pm_iir = I915_READ(GEN6_PMIIR);
1169 pm_mask = I915_READ(GEN6_PMINTRMSK);
1170 } else {
1171 pm_ier = I915_READ(GEN8_GT_IER(2));
1172 pm_imr = I915_READ(GEN8_GT_IMR(2));
1173 pm_isr = I915_READ(GEN8_GT_ISR(2));
1174 pm_iir = I915_READ(GEN8_GT_IIR(2));
1175 pm_mask = I915_READ(GEN6_PMINTRMSK);
1176 }
Sagar Arun Kamble960e5462017-10-10 22:29:59 +01001177 seq_printf(m, "Video Turbo Mode: %s\n",
1178 yesno(rpmodectl & GEN6_RP_MEDIA_TURBO));
1179 seq_printf(m, "HW control enabled: %s\n",
1180 yesno(rpmodectl & GEN6_RP_ENABLE));
1181 seq_printf(m, "SW control enabled: %s\n",
1182 yesno((rpmodectl & GEN6_RP_MEDIA_MODE_MASK) ==
1183 GEN6_RP_MEDIA_SW_MODE));
Chris Wilson0d8f9492014-03-27 09:06:14 +00001184 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 -03001185 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask);
Sagar Arun Kamble5dd04552017-03-11 08:07:00 +05301186 seq_printf(m, "pm_intrmsk_mbz: 0x%08x\n",
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01001187 rps->pm_intrmsk_mbz);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001188 seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001189 seq_printf(m, "Render p-state ratio: %d\n",
Rodrigo Vivi35ceabf2017-07-06 13:41:13 -07001190 (gt_perf_status & (INTEL_GEN(dev_priv) >= 9 ? 0x1ff00 : 0xff00)) >> 8);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001191 seq_printf(m, "Render p-state VID: %d\n",
1192 gt_perf_status & 0xff);
1193 seq_printf(m, "Render p-state limit: %d\n",
1194 rp_state_limits & 0xff);
Chris Wilson0d8f9492014-03-27 09:06:14 +00001195 seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat);
1196 seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl);
1197 seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit);
1198 seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit);
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001199 seq_printf(m, "RPNSWREQ: %dMHz\n", reqf);
Ben Widawskyf82855d2013-01-29 12:00:15 -08001200 seq_printf(m, "CAGF: %dMHz\n", cagf);
Akash Goeld6cda9c2016-04-23 00:05:46 +05301201 seq_printf(m, "RP CUR UP EI: %d (%dus)\n",
1202 rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei));
1203 seq_printf(m, "RP CUR UP: %d (%dus)\n",
1204 rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup));
1205 seq_printf(m, "RP PREV UP: %d (%dus)\n",
1206 rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup));
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01001207 seq_printf(m, "Up threshold: %d%%\n", rps->up_threshold);
Chris Wilsond86ed342015-04-27 13:41:19 +01001208
Akash Goeld6cda9c2016-04-23 00:05:46 +05301209 seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n",
1210 rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei));
1211 seq_printf(m, "RP CUR DOWN: %d (%dus)\n",
1212 rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown));
1213 seq_printf(m, "RP PREV DOWN: %d (%dus)\n",
1214 rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown));
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01001215 seq_printf(m, "Down threshold: %d%%\n", rps->down_threshold);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001216
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02001217 max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 0 :
Bob Paauwe35040562015-06-25 14:54:07 -07001218 rp_state_cap >> 16) & 0xff;
Rodrigo Vivi35ceabf2017-07-06 13:41:13 -07001219 max_freq *= (IS_GEN9_BC(dev_priv) ||
1220 IS_CANNONLAKE(dev_priv) ? GEN9_FREQ_SCALER : 1);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001221 seq_printf(m, "Lowest (RPN) frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001222 intel_gpu_freq(dev_priv, max_freq));
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001223
1224 max_freq = (rp_state_cap & 0xff00) >> 8;
Rodrigo Vivi35ceabf2017-07-06 13:41:13 -07001225 max_freq *= (IS_GEN9_BC(dev_priv) ||
1226 IS_CANNONLAKE(dev_priv) ? GEN9_FREQ_SCALER : 1);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001227 seq_printf(m, "Nominal (RP1) frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001228 intel_gpu_freq(dev_priv, max_freq));
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001229
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02001230 max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 16 :
Bob Paauwe35040562015-06-25 14:54:07 -07001231 rp_state_cap >> 0) & 0xff;
Rodrigo Vivi35ceabf2017-07-06 13:41:13 -07001232 max_freq *= (IS_GEN9_BC(dev_priv) ||
1233 IS_CANNONLAKE(dev_priv) ? GEN9_FREQ_SCALER : 1);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001234 seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n",
Ville Syrjälä7c59a9c12015-01-23 21:04:26 +02001235 intel_gpu_freq(dev_priv, max_freq));
Ben Widawsky31c77382013-04-05 14:29:22 -07001236 seq_printf(m, "Max overclocked frequency: %dMHz\n",
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01001237 intel_gpu_freq(dev_priv, rps->max_freq));
Chris Wilsonaed242f2015-03-18 09:48:21 +00001238
Chris Wilsond86ed342015-04-27 13:41:19 +01001239 seq_printf(m, "Current freq: %d MHz\n",
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01001240 intel_gpu_freq(dev_priv, rps->cur_freq));
Chris Wilsond86ed342015-04-27 13:41:19 +01001241 seq_printf(m, "Actual freq: %d MHz\n", cagf);
Chris Wilsonaed242f2015-03-18 09:48:21 +00001242 seq_printf(m, "Idle freq: %d MHz\n",
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01001243 intel_gpu_freq(dev_priv, rps->idle_freq));
Chris Wilsond86ed342015-04-27 13:41:19 +01001244 seq_printf(m, "Min freq: %d MHz\n",
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01001245 intel_gpu_freq(dev_priv, rps->min_freq));
Chris Wilson29ecd78d2016-07-13 09:10:35 +01001246 seq_printf(m, "Boost freq: %d MHz\n",
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01001247 intel_gpu_freq(dev_priv, rps->boost_freq));
Chris Wilsond86ed342015-04-27 13:41:19 +01001248 seq_printf(m, "Max freq: %d MHz\n",
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01001249 intel_gpu_freq(dev_priv, rps->max_freq));
Chris Wilsond86ed342015-04-27 13:41:19 +01001250 seq_printf(m,
1251 "efficient (RPe) frequency: %d MHz\n",
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01001252 intel_gpu_freq(dev_priv, rps->efficient_freq));
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001253 } else {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001254 seq_puts(m, "no P-state info available\n");
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001255 }
Jesse Barnesf97108d2010-01-29 11:27:07 -08001256
Ville Syrjälä49cd97a2017-02-07 20:33:45 +02001257 seq_printf(m, "Current CD clock frequency: %d kHz\n", dev_priv->cdclk.hw.cdclk);
Mika Kahola1170f282015-09-25 14:00:32 +03001258 seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq);
1259 seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq);
1260
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001261 intel_runtime_pm_put(dev_priv);
1262 return ret;
Jesse Barnesf97108d2010-01-29 11:27:07 -08001263}
1264
Ben Widawskyd6369512016-09-20 16:54:32 +03001265static void i915_instdone_info(struct drm_i915_private *dev_priv,
1266 struct seq_file *m,
1267 struct intel_instdone *instdone)
1268{
Ben Widawskyf9e61372016-09-20 16:54:33 +03001269 int slice;
1270 int subslice;
1271
Ben Widawskyd6369512016-09-20 16:54:32 +03001272 seq_printf(m, "\t\tINSTDONE: 0x%08x\n",
1273 instdone->instdone);
1274
1275 if (INTEL_GEN(dev_priv) <= 3)
1276 return;
1277
1278 seq_printf(m, "\t\tSC_INSTDONE: 0x%08x\n",
1279 instdone->slice_common);
1280
1281 if (INTEL_GEN(dev_priv) <= 6)
1282 return;
1283
Ben Widawskyf9e61372016-09-20 16:54:33 +03001284 for_each_instdone_slice_subslice(dev_priv, slice, subslice)
1285 seq_printf(m, "\t\tSAMPLER_INSTDONE[%d][%d]: 0x%08x\n",
1286 slice, subslice, instdone->sampler[slice][subslice]);
1287
1288 for_each_instdone_slice_subslice(dev_priv, slice, subslice)
1289 seq_printf(m, "\t\tROW_INSTDONE[%d][%d]: 0x%08x\n",
1290 slice, subslice, instdone->row[slice][subslice]);
Ben Widawskyd6369512016-09-20 16:54:32 +03001291}
1292
Chris Wilsonf6544492015-01-26 18:03:04 +02001293static int i915_hangcheck_info(struct seq_file *m, void *unused)
1294{
David Weinehall36cdd012016-08-22 13:59:31 +03001295 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001296 struct intel_engine_cs *engine;
Tvrtko Ursulin666796d2016-03-16 11:00:39 +00001297 u64 acthd[I915_NUM_ENGINES];
1298 u32 seqno[I915_NUM_ENGINES];
Ben Widawskyd6369512016-09-20 16:54:32 +03001299 struct intel_instdone instdone;
Dave Gordonc3232b12016-03-23 18:19:53 +00001300 enum intel_engine_id id;
Chris Wilsonf6544492015-01-26 18:03:04 +02001301
Chris Wilson8af29b02016-09-09 14:11:47 +01001302 if (test_bit(I915_WEDGED, &dev_priv->gpu_error.flags))
Chris Wilson8c185ec2017-03-16 17:13:02 +00001303 seq_puts(m, "Wedged\n");
1304 if (test_bit(I915_RESET_BACKOFF, &dev_priv->gpu_error.flags))
1305 seq_puts(m, "Reset in progress: struct_mutex backoff\n");
1306 if (test_bit(I915_RESET_HANDOFF, &dev_priv->gpu_error.flags))
1307 seq_puts(m, "Reset in progress: reset handoff to waiter\n");
Chris Wilson8af29b02016-09-09 14:11:47 +01001308 if (waitqueue_active(&dev_priv->gpu_error.wait_queue))
Chris Wilson8c185ec2017-03-16 17:13:02 +00001309 seq_puts(m, "Waiter holding struct mutex\n");
Chris Wilson8af29b02016-09-09 14:11:47 +01001310 if (waitqueue_active(&dev_priv->gpu_error.reset_queue))
Chris Wilson8c185ec2017-03-16 17:13:02 +00001311 seq_puts(m, "struct_mutex blocked for reset\n");
Chris Wilson8af29b02016-09-09 14:11:47 +01001312
Michal Wajdeczko4f044a82017-09-19 19:38:44 +00001313 if (!i915_modparams.enable_hangcheck) {
Chris Wilson8c185ec2017-03-16 17:13:02 +00001314 seq_puts(m, "Hangcheck disabled\n");
Chris Wilsonf6544492015-01-26 18:03:04 +02001315 return 0;
1316 }
1317
Mika Kuoppalaebbc7542015-02-05 18:41:48 +02001318 intel_runtime_pm_get(dev_priv);
1319
Akash Goel3b3f1652016-10-13 22:44:48 +05301320 for_each_engine(engine, dev_priv, id) {
Chris Wilson7e37f882016-08-02 22:50:21 +01001321 acthd[id] = intel_engine_get_active_head(engine);
Chris Wilson1b7744e2016-07-01 17:23:17 +01001322 seqno[id] = intel_engine_get_seqno(engine);
Mika Kuoppalaebbc7542015-02-05 18:41:48 +02001323 }
1324
Akash Goel3b3f1652016-10-13 22:44:48 +05301325 intel_engine_get_instdone(dev_priv->engine[RCS], &instdone);
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001326
Mika Kuoppalaebbc7542015-02-05 18:41:48 +02001327 intel_runtime_pm_put(dev_priv);
1328
Chris Wilson8352aea2017-03-03 09:00:56 +00001329 if (timer_pending(&dev_priv->gpu_error.hangcheck_work.timer))
1330 seq_printf(m, "Hangcheck active, timer fires in %dms\n",
Chris Wilsonf6544492015-01-26 18:03:04 +02001331 jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires -
1332 jiffies));
Chris Wilson8352aea2017-03-03 09:00:56 +00001333 else if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work))
1334 seq_puts(m, "Hangcheck active, work pending\n");
1335 else
1336 seq_puts(m, "Hangcheck inactive\n");
Chris Wilsonf6544492015-01-26 18:03:04 +02001337
Chris Wilsonf73b5672017-03-02 15:03:56 +00001338 seq_printf(m, "GT active? %s\n", yesno(dev_priv->gt.awake));
1339
Akash Goel3b3f1652016-10-13 22:44:48 +05301340 for_each_engine(engine, dev_priv, id) {
Chris Wilson33f53712016-10-04 21:11:32 +01001341 struct intel_breadcrumbs *b = &engine->breadcrumbs;
1342 struct rb_node *rb;
1343
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001344 seq_printf(m, "%s:\n", engine->name);
Chris Wilsonf73b5672017-03-02 15:03:56 +00001345 seq_printf(m, "\tseqno = %x [current %x, last %x], inflight %d\n",
Chris Wilsoncb399ea2016-11-01 10:03:16 +00001346 engine->hangcheck.seqno, seqno[id],
Chris Wilsonf73b5672017-03-02 15:03:56 +00001347 intel_engine_last_submit(engine),
1348 engine->timeline->inflight_seqnos);
Mika Kuoppala3fe3b032016-11-18 15:09:04 +02001349 seq_printf(m, "\twaiters? %s, fake irq active? %s, stalled? %s\n",
Chris Wilson83348ba2016-08-09 17:47:51 +01001350 yesno(intel_engine_has_waiter(engine)),
1351 yesno(test_bit(engine->id,
Mika Kuoppala3fe3b032016-11-18 15:09:04 +02001352 &dev_priv->gpu_error.missed_irq_rings)),
1353 yesno(engine->hangcheck.stalled));
1354
Chris Wilson61d3dc72017-03-03 19:08:24 +00001355 spin_lock_irq(&b->rb_lock);
Chris Wilson33f53712016-10-04 21:11:32 +01001356 for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) {
Geliang Tangf802cf72016-12-19 22:43:49 +08001357 struct intel_wait *w = rb_entry(rb, typeof(*w), node);
Chris Wilson33f53712016-10-04 21:11:32 +01001358
1359 seq_printf(m, "\t%s [%d] waiting for %x\n",
1360 w->tsk->comm, w->tsk->pid, w->seqno);
1361 }
Chris Wilson61d3dc72017-03-03 19:08:24 +00001362 spin_unlock_irq(&b->rb_lock);
Chris Wilson33f53712016-10-04 21:11:32 +01001363
Chris Wilsonf6544492015-01-26 18:03:04 +02001364 seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001365 (long long)engine->hangcheck.acthd,
Dave Gordonc3232b12016-03-23 18:19:53 +00001366 (long long)acthd[id]);
Mika Kuoppala3fe3b032016-11-18 15:09:04 +02001367 seq_printf(m, "\taction = %s(%d) %d ms ago\n",
1368 hangcheck_action_to_str(engine->hangcheck.action),
1369 engine->hangcheck.action,
1370 jiffies_to_msecs(jiffies -
1371 engine->hangcheck.action_timestamp));
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001372
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001373 if (engine->id == RCS) {
Ben Widawskyd6369512016-09-20 16:54:32 +03001374 seq_puts(m, "\tinstdone read =\n");
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001375
Ben Widawskyd6369512016-09-20 16:54:32 +03001376 i915_instdone_info(dev_priv, m, &instdone);
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001377
Ben Widawskyd6369512016-09-20 16:54:32 +03001378 seq_puts(m, "\tinstdone accu =\n");
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001379
Ben Widawskyd6369512016-09-20 16:54:32 +03001380 i915_instdone_info(dev_priv, m,
1381 &engine->hangcheck.instdone);
Mika Kuoppala61642ff2015-12-01 17:56:12 +02001382 }
Chris Wilsonf6544492015-01-26 18:03:04 +02001383 }
1384
1385 return 0;
1386}
1387
Michel Thierry061d06a2017-06-20 10:57:49 +01001388static int i915_reset_info(struct seq_file *m, void *unused)
1389{
1390 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1391 struct i915_gpu_error *error = &dev_priv->gpu_error;
1392 struct intel_engine_cs *engine;
1393 enum intel_engine_id id;
1394
1395 seq_printf(m, "full gpu reset = %u\n", i915_reset_count(error));
1396
1397 for_each_engine(engine, dev_priv, id) {
1398 seq_printf(m, "%s = %u\n", engine->name,
1399 i915_reset_engine_count(error, engine));
1400 }
1401
1402 return 0;
1403}
1404
Ben Widawsky4d855292011-12-12 19:34:16 -08001405static int ironlake_drpc_info(struct seq_file *m)
Jesse Barnesf97108d2010-01-29 11:27:07 -08001406{
David Weinehall36cdd012016-08-22 13:59:31 +03001407 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Ben Widawsky616fdb52011-10-05 11:44:54 -07001408 u32 rgvmodectl, rstdbyctl;
1409 u16 crstandvid;
Ben Widawsky616fdb52011-10-05 11:44:54 -07001410
Ben Widawsky616fdb52011-10-05 11:44:54 -07001411 rgvmodectl = I915_READ(MEMMODECTL);
1412 rstdbyctl = I915_READ(RSTDBYCTL);
1413 crstandvid = I915_READ16(CRSTANDVID);
1414
Jani Nikula742f4912015-09-03 11:16:09 +03001415 seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001416 seq_printf(m, "Boost freq: %d\n",
1417 (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >>
1418 MEMMODE_BOOST_FREQ_SHIFT);
1419 seq_printf(m, "HW control enabled: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001420 yesno(rgvmodectl & MEMMODE_HWIDLE_EN));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001421 seq_printf(m, "SW control enabled: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001422 yesno(rgvmodectl & MEMMODE_SWMODE_EN));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001423 seq_printf(m, "Gated voltage change: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001424 yesno(rgvmodectl & MEMMODE_RCLK_GATE));
Jesse Barnesf97108d2010-01-29 11:27:07 -08001425 seq_printf(m, "Starting frequency: P%d\n",
1426 (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001427 seq_printf(m, "Max P-state: P%d\n",
Jesse Barnesf97108d2010-01-29 11:27:07 -08001428 (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001429 seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK));
1430 seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f));
1431 seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f));
1432 seq_printf(m, "Render standby enabled: %s\n",
Jani Nikula742f4912015-09-03 11:16:09 +03001433 yesno(!(rstdbyctl & RCX_SW_EXIT)));
Damien Lespiau267f0c92013-06-24 22:59:48 +01001434 seq_puts(m, "Current RS state: ");
Jesse Barnes88271da2011-01-05 12:01:24 -08001435 switch (rstdbyctl & RSX_STATUS_MASK) {
1436 case RSX_STATUS_ON:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001437 seq_puts(m, "on\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001438 break;
1439 case RSX_STATUS_RC1:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001440 seq_puts(m, "RC1\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001441 break;
1442 case RSX_STATUS_RC1E:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001443 seq_puts(m, "RC1E\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001444 break;
1445 case RSX_STATUS_RS1:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001446 seq_puts(m, "RS1\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001447 break;
1448 case RSX_STATUS_RS2:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001449 seq_puts(m, "RS2 (RC6)\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001450 break;
1451 case RSX_STATUS_RS3:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001452 seq_puts(m, "RC3 (RC6+)\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001453 break;
1454 default:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001455 seq_puts(m, "unknown\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001456 break;
1457 }
Jesse Barnesf97108d2010-01-29 11:27:07 -08001458
1459 return 0;
1460}
1461
Mika Kuoppalaf65367b2015-01-16 11:34:42 +02001462static int i915_forcewake_domains(struct seq_file *m, void *data)
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001463{
Chris Wilson233ebf52017-03-23 10:19:44 +00001464 struct drm_i915_private *i915 = node_to_i915(m->private);
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001465 struct intel_uncore_forcewake_domain *fw_domain;
Chris Wilsond2dc94b2017-03-23 10:19:41 +00001466 unsigned int tmp;
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001467
Chris Wilsond7a133d2017-09-07 14:44:41 +01001468 seq_printf(m, "user.bypass_count = %u\n",
1469 i915->uncore.user_forcewake.count);
1470
Chris Wilson233ebf52017-03-23 10:19:44 +00001471 for_each_fw_domain(fw_domain, i915, tmp)
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001472 seq_printf(m, "%s.wake_count = %u\n",
Tvrtko Ursulin33c582c2016-04-07 17:04:33 +01001473 intel_uncore_forcewake_domain_to_str(fw_domain->id),
Chris Wilson233ebf52017-03-23 10:19:44 +00001474 READ_ONCE(fw_domain->wake_count));
Chris Wilsonb2cff0d2015-01-16 11:34:37 +02001475
1476 return 0;
1477}
1478
Mika Kuoppala13628772017-03-15 17:43:02 +02001479static void print_rc6_res(struct seq_file *m,
1480 const char *title,
1481 const i915_reg_t reg)
1482{
1483 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1484
1485 seq_printf(m, "%s %u (%llu us)\n",
1486 title, I915_READ(reg),
1487 intel_rc6_residency_us(dev_priv, reg));
1488}
1489
Deepak S669ab5a2014-01-10 15:18:26 +05301490static int vlv_drpc_info(struct seq_file *m)
1491{
David Weinehall36cdd012016-08-22 13:59:31 +03001492 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Sagar Arun Kamble0d6fc922017-10-10 22:30:02 +01001493 u32 rcctl1, pw_status;
Deepak S669ab5a2014-01-10 15:18:26 +05301494
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001495 pw_status = I915_READ(VLV_GTLC_PW_STATUS);
Deepak S669ab5a2014-01-10 15:18:26 +05301496 rcctl1 = I915_READ(GEN6_RC_CONTROL);
1497
Deepak S669ab5a2014-01-10 15:18:26 +05301498 seq_printf(m, "RC6 Enabled: %s\n",
1499 yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE |
1500 GEN6_RC_CTL_EI_MODE(1))));
1501 seq_printf(m, "Render Power Well: %s\n",
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001502 (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down");
Deepak S669ab5a2014-01-10 15:18:26 +05301503 seq_printf(m, "Media Power Well: %s\n",
Ville Syrjälä6b312cd2014-11-19 20:07:42 +02001504 (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down");
Deepak S669ab5a2014-01-10 15:18:26 +05301505
Mika Kuoppala13628772017-03-15 17:43:02 +02001506 print_rc6_res(m, "Render RC6 residency since boot:", VLV_GT_RENDER_RC6);
1507 print_rc6_res(m, "Media RC6 residency since boot:", VLV_GT_MEDIA_RC6);
Imre Deak9cc19be2014-04-14 20:24:24 +03001508
Mika Kuoppalaf65367b2015-01-16 11:34:42 +02001509 return i915_forcewake_domains(m, NULL);
Deepak S669ab5a2014-01-10 15:18:26 +05301510}
1511
Ben Widawsky4d855292011-12-12 19:34:16 -08001512static int gen6_drpc_info(struct seq_file *m)
1513{
David Weinehall36cdd012016-08-22 13:59:31 +03001514 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Sagar Arun Kamble960e5462017-10-10 22:29:59 +01001515 u32 gt_core_status, rcctl1, rc6vids = 0;
Akash Goelf2dd7572016-06-27 20:10:01 +05301516 u32 gen9_powergate_enable = 0, gen9_powergate_status = 0;
Daniel Vetter93b525d2012-01-25 13:52:43 +01001517 unsigned forcewake_count;
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001518 int count = 0;
Ben Widawsky4d855292011-12-12 19:34:16 -08001519
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001520 forcewake_count = READ_ONCE(dev_priv->uncore.fw_domain[FW_DOMAIN_ID_RENDER].wake_count);
Daniel Vetter93b525d2012-01-25 13:52:43 +01001521 if (forcewake_count) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001522 seq_puts(m, "RC information inaccurate because somebody "
1523 "holds a forcewake reference \n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001524 } else {
1525 /* NB: we cannot use forcewake, else we read the wrong values */
1526 while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1))
1527 udelay(10);
1528 seq_printf(m, "RC information accurate: %s\n", yesno(count < 51));
1529 }
1530
Ville Syrjälä75aa3f62015-10-22 15:34:56 +03001531 gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS);
Chris Wilsoned71f1b2013-07-19 20:36:56 +01001532 trace_i915_reg_rw(false, GEN6_GT_CORE_STATUS, gt_core_status, 4, true);
Ben Widawsky4d855292011-12-12 19:34:16 -08001533
Ben Widawsky4d855292011-12-12 19:34:16 -08001534 rcctl1 = I915_READ(GEN6_RC_CONTROL);
David Weinehall36cdd012016-08-22 13:59:31 +03001535 if (INTEL_GEN(dev_priv) >= 9) {
Akash Goelf2dd7572016-06-27 20:10:01 +05301536 gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE);
1537 gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS);
1538 }
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001539
Sagar Arun Kamble9f817502017-10-10 22:30:05 +01001540 mutex_lock(&dev_priv->pcu_lock);
Ben Widawsky44cbd332012-11-06 14:36:36 +00001541 sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids);
Sagar Arun Kamble9f817502017-10-10 22:30:05 +01001542 mutex_unlock(&dev_priv->pcu_lock);
Ben Widawsky4d855292011-12-12 19:34:16 -08001543
Eric Anholtfff24e22012-01-23 16:14:05 -08001544 seq_printf(m, "RC1e Enabled: %s\n",
Ben Widawsky4d855292011-12-12 19:34:16 -08001545 yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE));
1546 seq_printf(m, "RC6 Enabled: %s\n",
1547 yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE));
David Weinehall36cdd012016-08-22 13:59:31 +03001548 if (INTEL_GEN(dev_priv) >= 9) {
Akash Goelf2dd7572016-06-27 20:10:01 +05301549 seq_printf(m, "Render Well Gating Enabled: %s\n",
1550 yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE));
1551 seq_printf(m, "Media Well Gating Enabled: %s\n",
1552 yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE));
1553 }
Ben Widawsky4d855292011-12-12 19:34:16 -08001554 seq_printf(m, "Deep RC6 Enabled: %s\n",
1555 yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE));
1556 seq_printf(m, "Deepest RC6 Enabled: %s\n",
1557 yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE));
Damien Lespiau267f0c92013-06-24 22:59:48 +01001558 seq_puts(m, "Current RC state: ");
Ben Widawsky4d855292011-12-12 19:34:16 -08001559 switch (gt_core_status & GEN6_RCn_MASK) {
1560 case GEN6_RC0:
1561 if (gt_core_status & GEN6_CORE_CPD_STATE_MASK)
Damien Lespiau267f0c92013-06-24 22:59:48 +01001562 seq_puts(m, "Core Power Down\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001563 else
Damien Lespiau267f0c92013-06-24 22:59:48 +01001564 seq_puts(m, "on\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001565 break;
1566 case GEN6_RC3:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001567 seq_puts(m, "RC3\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001568 break;
1569 case GEN6_RC6:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001570 seq_puts(m, "RC6\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001571 break;
1572 case GEN6_RC7:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001573 seq_puts(m, "RC7\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001574 break;
1575 default:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001576 seq_puts(m, "Unknown\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001577 break;
1578 }
1579
1580 seq_printf(m, "Core Power Down: %s\n",
1581 yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK));
David Weinehall36cdd012016-08-22 13:59:31 +03001582 if (INTEL_GEN(dev_priv) >= 9) {
Akash Goelf2dd7572016-06-27 20:10:01 +05301583 seq_printf(m, "Render Power Well: %s\n",
1584 (gen9_powergate_status &
1585 GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down");
1586 seq_printf(m, "Media Power Well: %s\n",
1587 (gen9_powergate_status &
1588 GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down");
1589 }
Ben Widawskycce66a22012-03-27 18:59:38 -07001590
1591 /* Not exactly sure what this is */
Mika Kuoppala13628772017-03-15 17:43:02 +02001592 print_rc6_res(m, "RC6 \"Locked to RPn\" residency since boot:",
1593 GEN6_GT_GFX_RC6_LOCKED);
1594 print_rc6_res(m, "RC6 residency since boot:", GEN6_GT_GFX_RC6);
1595 print_rc6_res(m, "RC6+ residency since boot:", GEN6_GT_GFX_RC6p);
1596 print_rc6_res(m, "RC6++ residency since boot:", GEN6_GT_GFX_RC6pp);
Ben Widawskycce66a22012-03-27 18:59:38 -07001597
Ben Widawskyecd8fae2012-09-26 10:34:02 -07001598 seq_printf(m, "RC6 voltage: %dmV\n",
1599 GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff)));
1600 seq_printf(m, "RC6+ voltage: %dmV\n",
1601 GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff)));
1602 seq_printf(m, "RC6++ voltage: %dmV\n",
1603 GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff)));
Akash Goelf2dd7572016-06-27 20:10:01 +05301604 return i915_forcewake_domains(m, NULL);
Ben Widawsky4d855292011-12-12 19:34:16 -08001605}
1606
1607static int i915_drpc_info(struct seq_file *m, void *unused)
1608{
David Weinehall36cdd012016-08-22 13:59:31 +03001609 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001610 int err;
1611
1612 intel_runtime_pm_get(dev_priv);
Ben Widawsky4d855292011-12-12 19:34:16 -08001613
David Weinehall36cdd012016-08-22 13:59:31 +03001614 if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001615 err = vlv_drpc_info(m);
David Weinehall36cdd012016-08-22 13:59:31 +03001616 else if (INTEL_GEN(dev_priv) >= 6)
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001617 err = gen6_drpc_info(m);
Ben Widawsky4d855292011-12-12 19:34:16 -08001618 else
Chris Wilsoncf632bd2017-03-13 09:56:17 +00001619 err = ironlake_drpc_info(m);
1620
1621 intel_runtime_pm_put(dev_priv);
1622
1623 return err;
Ben Widawsky4d855292011-12-12 19:34:16 -08001624}
1625
Daniel Vetter9a851782015-06-18 10:30:22 +02001626static int i915_frontbuffer_tracking(struct seq_file *m, void *unused)
1627{
David Weinehall36cdd012016-08-22 13:59:31 +03001628 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Daniel Vetter9a851782015-06-18 10:30:22 +02001629
1630 seq_printf(m, "FB tracking busy bits: 0x%08x\n",
1631 dev_priv->fb_tracking.busy_bits);
1632
1633 seq_printf(m, "FB tracking flip bits: 0x%08x\n",
1634 dev_priv->fb_tracking.flip_bits);
1635
1636 return 0;
1637}
1638
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001639static int i915_fbc_status(struct seq_file *m, void *unused)
1640{
David Weinehall36cdd012016-08-22 13:59:31 +03001641 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001642
David Weinehall36cdd012016-08-22 13:59:31 +03001643 if (!HAS_FBC(dev_priv)) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001644 seq_puts(m, "FBC unsupported on this chipset\n");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001645 return 0;
1646 }
1647
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001648 intel_runtime_pm_get(dev_priv);
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001649 mutex_lock(&dev_priv->fbc.lock);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001650
Paulo Zanoni0e631ad2015-10-14 17:45:36 -03001651 if (intel_fbc_is_active(dev_priv))
Damien Lespiau267f0c92013-06-24 22:59:48 +01001652 seq_puts(m, "FBC enabled\n");
Paulo Zanoni2e8144a2015-06-12 14:36:20 -03001653 else
1654 seq_printf(m, "FBC disabled: %s\n",
Paulo Zanonibf6189c2015-10-27 14:50:03 -02001655 dev_priv->fbc.no_fbc_reason);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001656
Ville Syrjälä3fd5d1e2017-06-06 15:43:18 +03001657 if (intel_fbc_is_active(dev_priv)) {
1658 u32 mask;
1659
1660 if (INTEL_GEN(dev_priv) >= 8)
1661 mask = I915_READ(IVB_FBC_STATUS2) & BDW_FBC_COMP_SEG_MASK;
1662 else if (INTEL_GEN(dev_priv) >= 7)
1663 mask = I915_READ(IVB_FBC_STATUS2) & IVB_FBC_COMP_SEG_MASK;
1664 else if (INTEL_GEN(dev_priv) >= 5)
1665 mask = I915_READ(ILK_DPFC_STATUS) & ILK_DPFC_COMP_SEG_MASK;
1666 else if (IS_G4X(dev_priv))
1667 mask = I915_READ(DPFC_STATUS) & DPFC_COMP_SEG_MASK;
1668 else
1669 mask = I915_READ(FBC_STATUS) & (FBC_STAT_COMPRESSING |
1670 FBC_STAT_COMPRESSED);
1671
1672 seq_printf(m, "Compressing: %s\n", yesno(mask));
Paulo Zanoni0fc6a9d2016-10-21 13:55:46 -02001673 }
Paulo Zanoni31b9df12015-06-12 14:36:18 -03001674
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001675 mutex_unlock(&dev_priv->fbc.lock);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001676 intel_runtime_pm_put(dev_priv);
1677
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001678 return 0;
1679}
1680
Ville Syrjälä4127dc42017-06-06 15:44:12 +03001681static int i915_fbc_false_color_get(void *data, u64 *val)
Rodrigo Vivida46f932014-08-01 02:04:45 -07001682{
David Weinehall36cdd012016-08-22 13:59:31 +03001683 struct drm_i915_private *dev_priv = data;
Rodrigo Vivida46f932014-08-01 02:04:45 -07001684
David Weinehall36cdd012016-08-22 13:59:31 +03001685 if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv))
Rodrigo Vivida46f932014-08-01 02:04:45 -07001686 return -ENODEV;
1687
Rodrigo Vivida46f932014-08-01 02:04:45 -07001688 *val = dev_priv->fbc.false_color;
Rodrigo Vivida46f932014-08-01 02:04:45 -07001689
1690 return 0;
1691}
1692
Ville Syrjälä4127dc42017-06-06 15:44:12 +03001693static int i915_fbc_false_color_set(void *data, u64 val)
Rodrigo Vivida46f932014-08-01 02:04:45 -07001694{
David Weinehall36cdd012016-08-22 13:59:31 +03001695 struct drm_i915_private *dev_priv = data;
Rodrigo Vivida46f932014-08-01 02:04:45 -07001696 u32 reg;
1697
David Weinehall36cdd012016-08-22 13:59:31 +03001698 if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv))
Rodrigo Vivida46f932014-08-01 02:04:45 -07001699 return -ENODEV;
1700
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001701 mutex_lock(&dev_priv->fbc.lock);
Rodrigo Vivida46f932014-08-01 02:04:45 -07001702
1703 reg = I915_READ(ILK_DPFC_CONTROL);
1704 dev_priv->fbc.false_color = val;
1705
1706 I915_WRITE(ILK_DPFC_CONTROL, val ?
1707 (reg | FBC_CTL_FALSE_COLOR) :
1708 (reg & ~FBC_CTL_FALSE_COLOR));
1709
Paulo Zanoni25ad93f2015-07-02 19:25:10 -03001710 mutex_unlock(&dev_priv->fbc.lock);
Rodrigo Vivida46f932014-08-01 02:04:45 -07001711 return 0;
1712}
1713
Ville Syrjälä4127dc42017-06-06 15:44:12 +03001714DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_false_color_fops,
1715 i915_fbc_false_color_get, i915_fbc_false_color_set,
Rodrigo Vivida46f932014-08-01 02:04:45 -07001716 "%llu\n");
1717
Paulo Zanoni92d44622013-05-31 16:33:24 -03001718static int i915_ips_status(struct seq_file *m, void *unused)
1719{
David Weinehall36cdd012016-08-22 13:59:31 +03001720 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Paulo Zanoni92d44622013-05-31 16:33:24 -03001721
David Weinehall36cdd012016-08-22 13:59:31 +03001722 if (!HAS_IPS(dev_priv)) {
Paulo Zanoni92d44622013-05-31 16:33:24 -03001723 seq_puts(m, "not supported\n");
1724 return 0;
1725 }
1726
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001727 intel_runtime_pm_get(dev_priv);
1728
Rodrigo Vivi0eaa53f2014-06-30 04:45:01 -07001729 seq_printf(m, "Enabled by kernel parameter: %s\n",
Michal Wajdeczko4f044a82017-09-19 19:38:44 +00001730 yesno(i915_modparams.enable_ips));
Rodrigo Vivi0eaa53f2014-06-30 04:45:01 -07001731
David Weinehall36cdd012016-08-22 13:59:31 +03001732 if (INTEL_GEN(dev_priv) >= 8) {
Rodrigo Vivi0eaa53f2014-06-30 04:45:01 -07001733 seq_puts(m, "Currently: unknown\n");
1734 } else {
1735 if (I915_READ(IPS_CTL) & IPS_ENABLE)
1736 seq_puts(m, "Currently: enabled\n");
1737 else
1738 seq_puts(m, "Currently: disabled\n");
1739 }
Paulo Zanoni92d44622013-05-31 16:33:24 -03001740
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001741 intel_runtime_pm_put(dev_priv);
1742
Paulo Zanoni92d44622013-05-31 16:33:24 -03001743 return 0;
1744}
1745
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001746static int i915_sr_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);
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001749 bool sr_enabled = false;
1750
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001751 intel_runtime_pm_get(dev_priv);
Chris Wilson9c870d02016-10-24 13:42:15 +01001752 intel_display_power_get(dev_priv, POWER_DOMAIN_INIT);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001753
Chris Wilson7342a722017-03-09 14:20:49 +00001754 if (INTEL_GEN(dev_priv) >= 9)
1755 /* no global SR status; inspect per-plane WM */;
1756 else if (HAS_PCH_SPLIT(dev_priv))
Chris Wilson5ba2aaa2010-08-19 18:04:08 +01001757 sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN;
Jani Nikulac0f86832016-12-07 12:13:04 +02001758 else if (IS_I965GM(dev_priv) || IS_G4X(dev_priv) ||
David Weinehall36cdd012016-08-22 13:59:31 +03001759 IS_I945G(dev_priv) || IS_I945GM(dev_priv))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001760 sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
David Weinehall36cdd012016-08-22 13:59:31 +03001761 else if (IS_I915GM(dev_priv))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001762 sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN;
David Weinehall36cdd012016-08-22 13:59:31 +03001763 else if (IS_PINEVIEW(dev_priv))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001764 sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN;
David Weinehall36cdd012016-08-22 13:59:31 +03001765 else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
Ander Conselvan de Oliveira77b64552015-06-02 14:17:47 +03001766 sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN;
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001767
Chris Wilson9c870d02016-10-24 13:42:15 +01001768 intel_display_power_put(dev_priv, POWER_DOMAIN_INIT);
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001769 intel_runtime_pm_put(dev_priv);
1770
Tvrtko Ursulin08c4d7f2016-11-17 12:30:14 +00001771 seq_printf(m, "self-refresh: %s\n", enableddisabled(sr_enabled));
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001772
1773 return 0;
1774}
1775
Jesse Barnes7648fa92010-05-20 14:28:11 -07001776static int i915_emon_status(struct seq_file *m, void *unused)
1777{
David Weinehall36cdd012016-08-22 13:59:31 +03001778 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1779 struct drm_device *dev = &dev_priv->drm;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001780 unsigned long temp, chipset, gfx;
Chris Wilsonde227ef2010-07-03 07:58:38 +01001781 int ret;
1782
David Weinehall36cdd012016-08-22 13:59:31 +03001783 if (!IS_GEN5(dev_priv))
Chris Wilson582be6b2012-04-30 19:35:02 +01001784 return -ENODEV;
1785
Chris Wilsonde227ef2010-07-03 07:58:38 +01001786 ret = mutex_lock_interruptible(&dev->struct_mutex);
1787 if (ret)
1788 return ret;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001789
1790 temp = i915_mch_val(dev_priv);
1791 chipset = i915_chipset_val(dev_priv);
1792 gfx = i915_gfx_val(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +01001793 mutex_unlock(&dev->struct_mutex);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001794
1795 seq_printf(m, "GMCH temp: %ld\n", temp);
1796 seq_printf(m, "Chipset power: %ld\n", chipset);
1797 seq_printf(m, "GFX power: %ld\n", gfx);
1798 seq_printf(m, "Total power: %ld\n", chipset + gfx);
1799
1800 return 0;
1801}
1802
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001803static int i915_ring_freq_table(struct seq_file *m, void *unused)
1804{
David Weinehall36cdd012016-08-22 13:59:31 +03001805 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01001806 struct intel_rps *rps = &dev_priv->gt_pm.rps;
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001807 int ret = 0;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001808 int gpu_freq, ia_freq;
Akash Goelf936ec32015-06-29 14:50:22 +05301809 unsigned int max_gpu_freq, min_gpu_freq;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001810
Carlos Santa26310342016-08-17 12:30:41 -07001811 if (!HAS_LLC(dev_priv)) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001812 seq_puts(m, "unsupported on this chipset\n");
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001813 return 0;
1814 }
1815
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001816 intel_runtime_pm_get(dev_priv);
1817
Sagar Arun Kamble9f817502017-10-10 22:30:05 +01001818 ret = mutex_lock_interruptible(&dev_priv->pcu_lock);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001819 if (ret)
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001820 goto out;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001821
Rodrigo Vivi35ceabf2017-07-06 13:41:13 -07001822 if (IS_GEN9_BC(dev_priv) || IS_CANNONLAKE(dev_priv)) {
Akash Goelf936ec32015-06-29 14:50:22 +05301823 /* Convert GT frequency to 50 HZ units */
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01001824 min_gpu_freq = rps->min_freq_softlimit / GEN9_FREQ_SCALER;
1825 max_gpu_freq = rps->max_freq_softlimit / GEN9_FREQ_SCALER;
Akash Goelf936ec32015-06-29 14:50:22 +05301826 } else {
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01001827 min_gpu_freq = rps->min_freq_softlimit;
1828 max_gpu_freq = rps->max_freq_softlimit;
Akash Goelf936ec32015-06-29 14:50:22 +05301829 }
1830
Damien Lespiau267f0c92013-06-24 22:59:48 +01001831 seq_puts(m, "GPU freq (MHz)\tEffective CPU freq (MHz)\tEffective Ring freq (MHz)\n");
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001832
Akash Goelf936ec32015-06-29 14:50:22 +05301833 for (gpu_freq = min_gpu_freq; gpu_freq <= max_gpu_freq; gpu_freq++) {
Ben Widawsky42c05262012-09-26 10:34:00 -07001834 ia_freq = gpu_freq;
1835 sandybridge_pcode_read(dev_priv,
1836 GEN6_PCODE_READ_MIN_FREQ_TABLE,
1837 &ia_freq);
Chris Wilson3ebecd02013-04-12 19:10:13 +01001838 seq_printf(m, "%d\t\t%d\t\t\t\t%d\n",
Akash Goelf936ec32015-06-29 14:50:22 +05301839 intel_gpu_freq(dev_priv, (gpu_freq *
Rodrigo Vivi35ceabf2017-07-06 13:41:13 -07001840 (IS_GEN9_BC(dev_priv) ||
1841 IS_CANNONLAKE(dev_priv) ?
Rodrigo Vivib976dc52017-01-23 10:32:37 -08001842 GEN9_FREQ_SCALER : 1))),
Chris Wilson3ebecd02013-04-12 19:10:13 +01001843 ((ia_freq >> 0) & 0xff) * 100,
1844 ((ia_freq >> 8) & 0xff) * 100);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001845 }
1846
Sagar Arun Kamble9f817502017-10-10 22:30:05 +01001847 mutex_unlock(&dev_priv->pcu_lock);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001848
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001849out:
1850 intel_runtime_pm_put(dev_priv);
1851 return ret;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001852}
1853
Chris Wilson44834a62010-08-19 16:09:23 +01001854static int i915_opregion(struct seq_file *m, void *unused)
1855{
David Weinehall36cdd012016-08-22 13:59:31 +03001856 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1857 struct drm_device *dev = &dev_priv->drm;
Chris Wilson44834a62010-08-19 16:09:23 +01001858 struct intel_opregion *opregion = &dev_priv->opregion;
1859 int ret;
1860
1861 ret = mutex_lock_interruptible(&dev->struct_mutex);
1862 if (ret)
Daniel Vetter0d38f002012-04-21 22:49:10 +02001863 goto out;
Chris Wilson44834a62010-08-19 16:09:23 +01001864
Jani Nikula2455a8e2015-12-14 12:50:53 +02001865 if (opregion->header)
1866 seq_write(m, opregion->header, OPREGION_SIZE);
Chris Wilson44834a62010-08-19 16:09:23 +01001867
1868 mutex_unlock(&dev->struct_mutex);
1869
Daniel Vetter0d38f002012-04-21 22:49:10 +02001870out:
Chris Wilson44834a62010-08-19 16:09:23 +01001871 return 0;
1872}
1873
Jani Nikulaada8f952015-12-15 13:17:12 +02001874static int i915_vbt(struct seq_file *m, void *unused)
1875{
David Weinehall36cdd012016-08-22 13:59:31 +03001876 struct intel_opregion *opregion = &node_to_i915(m->private)->opregion;
Jani Nikulaada8f952015-12-15 13:17:12 +02001877
1878 if (opregion->vbt)
1879 seq_write(m, opregion->vbt, opregion->vbt_size);
1880
1881 return 0;
1882}
1883
Chris Wilson37811fc2010-08-25 22:45:57 +01001884static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
1885{
David Weinehall36cdd012016-08-22 13:59:31 +03001886 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1887 struct drm_device *dev = &dev_priv->drm;
Namrta Salonieb13b8402015-11-27 13:43:11 +05301888 struct intel_framebuffer *fbdev_fb = NULL;
Daniel Vetter3a58ee12015-07-10 19:02:51 +02001889 struct drm_framebuffer *drm_fb;
Chris Wilson188c1ab2016-04-03 14:14:20 +01001890 int ret;
1891
1892 ret = mutex_lock_interruptible(&dev->struct_mutex);
1893 if (ret)
1894 return ret;
Chris Wilson37811fc2010-08-25 22:45:57 +01001895
Daniel Vetter06957262015-08-10 13:34:08 +02001896#ifdef CONFIG_DRM_FBDEV_EMULATION
Daniel Vetter346fb4e2017-07-06 15:00:20 +02001897 if (dev_priv->fbdev && dev_priv->fbdev->helper.fb) {
David Weinehall36cdd012016-08-22 13:59:31 +03001898 fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb);
Chris Wilson37811fc2010-08-25 22:45:57 +01001899
Chris Wilson25bcce92016-07-02 15:36:00 +01001900 seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ",
1901 fbdev_fb->base.width,
1902 fbdev_fb->base.height,
Ville Syrjäläb00c6002016-12-14 23:31:35 +02001903 fbdev_fb->base.format->depth,
Ville Syrjälä272725c2016-12-14 23:32:20 +02001904 fbdev_fb->base.format->cpp[0] * 8,
Ville Syrjäläbae781b2016-11-16 13:33:16 +02001905 fbdev_fb->base.modifier,
Chris Wilson25bcce92016-07-02 15:36:00 +01001906 drm_framebuffer_read_refcount(&fbdev_fb->base));
1907 describe_obj(m, fbdev_fb->obj);
1908 seq_putc(m, '\n');
1909 }
Daniel Vetter4520f532013-10-09 09:18:51 +02001910#endif
Chris Wilson37811fc2010-08-25 22:45:57 +01001911
Daniel Vetter4b096ac2012-12-10 21:19:18 +01001912 mutex_lock(&dev->mode_config.fb_lock);
Daniel Vetter3a58ee12015-07-10 19:02:51 +02001913 drm_for_each_fb(drm_fb, dev) {
Namrta Salonieb13b8402015-11-27 13:43:11 +05301914 struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb);
1915 if (fb == fbdev_fb)
Chris Wilson37811fc2010-08-25 22:45:57 +01001916 continue;
1917
Tvrtko Ursulinc1ca506d2015-02-10 17:16:07 +00001918 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 +01001919 fb->base.width,
1920 fb->base.height,
Ville Syrjäläb00c6002016-12-14 23:31:35 +02001921 fb->base.format->depth,
Ville Syrjälä272725c2016-12-14 23:32:20 +02001922 fb->base.format->cpp[0] * 8,
Ville Syrjäläbae781b2016-11-16 13:33:16 +02001923 fb->base.modifier,
Dave Airlie747a5982016-04-15 15:10:35 +10001924 drm_framebuffer_read_refcount(&fb->base));
Chris Wilson05394f32010-11-08 19:18:58 +00001925 describe_obj(m, fb->obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +01001926 seq_putc(m, '\n');
Chris Wilson37811fc2010-08-25 22:45:57 +01001927 }
Daniel Vetter4b096ac2012-12-10 21:19:18 +01001928 mutex_unlock(&dev->mode_config.fb_lock);
Chris Wilson188c1ab2016-04-03 14:14:20 +01001929 mutex_unlock(&dev->struct_mutex);
Chris Wilson37811fc2010-08-25 22:45:57 +01001930
1931 return 0;
1932}
1933
Chris Wilson7e37f882016-08-02 22:50:21 +01001934static void describe_ctx_ring(struct seq_file *m, struct intel_ring *ring)
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001935{
Chris Wilsonfe085f12017-03-21 10:25:52 +00001936 seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u)",
1937 ring->space, ring->head, ring->tail);
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001938}
1939
Ben Widawskye76d3632011-03-19 18:14:29 -07001940static int i915_context_status(struct seq_file *m, void *unused)
1941{
David Weinehall36cdd012016-08-22 13:59:31 +03001942 struct drm_i915_private *dev_priv = node_to_i915(m->private);
1943 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00001944 struct intel_engine_cs *engine;
Chris Wilsone2efd132016-05-24 14:53:34 +01001945 struct i915_gem_context *ctx;
Akash Goel3b3f1652016-10-13 22:44:48 +05301946 enum intel_engine_id id;
Dave Gordonc3232b12016-03-23 18:19:53 +00001947 int ret;
Ben Widawskye76d3632011-03-19 18:14:29 -07001948
Daniel Vetterf3d28872014-05-29 23:23:08 +02001949 ret = mutex_lock_interruptible(&dev->struct_mutex);
Ben Widawskye76d3632011-03-19 18:14:29 -07001950 if (ret)
1951 return ret;
1952
Chris Wilson829a0af2017-06-20 12:05:45 +01001953 list_for_each_entry(ctx, &dev_priv->contexts.list, link) {
Chris Wilson5d1808e2016-04-28 09:56:51 +01001954 seq_printf(m, "HW context %u ", ctx->hw_id);
Chris Wilsonc84455b2016-08-15 10:49:08 +01001955 if (ctx->pid) {
Chris Wilsond28b99a2016-05-24 14:53:39 +01001956 struct task_struct *task;
1957
Chris Wilsonc84455b2016-08-15 10:49:08 +01001958 task = get_pid_task(ctx->pid, PIDTYPE_PID);
Chris Wilsond28b99a2016-05-24 14:53:39 +01001959 if (task) {
1960 seq_printf(m, "(%s [%d]) ",
1961 task->comm, task->pid);
1962 put_task_struct(task);
1963 }
Chris Wilsonc84455b2016-08-15 10:49:08 +01001964 } else if (IS_ERR(ctx->file_priv)) {
1965 seq_puts(m, "(deleted) ");
Chris Wilsond28b99a2016-05-24 14:53:39 +01001966 } else {
1967 seq_puts(m, "(kernel) ");
1968 }
1969
Chris Wilsonbca44d82016-05-24 14:53:41 +01001970 seq_putc(m, ctx->remap_slice ? 'R' : 'r');
1971 seq_putc(m, '\n');
Ben Widawskya33afea2013-09-17 21:12:45 -07001972
Akash Goel3b3f1652016-10-13 22:44:48 +05301973 for_each_engine(engine, dev_priv, id) {
Chris Wilsonbca44d82016-05-24 14:53:41 +01001974 struct intel_context *ce = &ctx->engine[engine->id];
1975
1976 seq_printf(m, "%s: ", engine->name);
1977 seq_putc(m, ce->initialised ? 'I' : 'i');
1978 if (ce->state)
Chris Wilsonbf3783e2016-08-15 10:48:54 +01001979 describe_obj(m, ce->state->obj);
Chris Wilsondca33ec2016-08-02 22:50:20 +01001980 if (ce->ring)
Chris Wilson7e37f882016-08-02 22:50:21 +01001981 describe_ctx_ring(m, ce->ring);
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001982 seq_putc(m, '\n');
Oscar Mateoc9fe99b2014-07-24 17:04:46 +01001983 }
1984
Ben Widawskya33afea2013-09-17 21:12:45 -07001985 seq_putc(m, '\n');
Ben Widawskya168c292013-02-14 15:05:12 -08001986 }
1987
Daniel Vetterf3d28872014-05-29 23:23:08 +02001988 mutex_unlock(&dev->struct_mutex);
Ben Widawskye76d3632011-03-19 18:14:29 -07001989
1990 return 0;
1991}
1992
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001993static void i915_dump_lrc_obj(struct seq_file *m,
Chris Wilsone2efd132016-05-24 14:53:34 +01001994 struct i915_gem_context *ctx,
Tvrtko Ursulin0bc40be2016-03-16 11:00:37 +00001995 struct intel_engine_cs *engine)
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001996{
Chris Wilsonbf3783e2016-08-15 10:48:54 +01001997 struct i915_vma *vma = ctx->engine[engine->id].state;
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001998 struct page *page;
Thomas Daniel064ca1d2014-12-02 13:21:18 +00001999 int j;
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002000
Chris Wilson7069b142016-04-28 09:56:52 +01002001 seq_printf(m, "CONTEXT: %s %u\n", engine->name, ctx->hw_id);
2002
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002003 if (!vma) {
2004 seq_puts(m, "\tFake context\n");
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002005 return;
2006 }
2007
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002008 if (vma->flags & I915_VMA_GLOBAL_BIND)
2009 seq_printf(m, "\tBound in GGTT at 0x%08x\n",
Chris Wilsonbde13eb2016-08-15 10:49:07 +01002010 i915_ggtt_offset(vma));
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002011
Chris Wilsona4f5ea62016-10-28 13:58:35 +01002012 if (i915_gem_object_pin_pages(vma->obj)) {
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002013 seq_puts(m, "\tFailed to get pages for context object\n\n");
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002014 return;
2015 }
2016
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002017 page = i915_gem_object_get_page(vma->obj, LRC_STATE_PN);
2018 if (page) {
2019 u32 *reg_state = kmap_atomic(page);
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002020
2021 for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) {
Chris Wilsonbf3783e2016-08-15 10:48:54 +01002022 seq_printf(m,
2023 "\t[0x%04x] 0x%08x 0x%08x 0x%08x 0x%08x\n",
2024 j * 4,
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002025 reg_state[j], reg_state[j + 1],
2026 reg_state[j + 2], reg_state[j + 3]);
2027 }
2028 kunmap_atomic(reg_state);
2029 }
2030
Chris Wilsona4f5ea62016-10-28 13:58:35 +01002031 i915_gem_object_unpin_pages(vma->obj);
Thomas Daniel064ca1d2014-12-02 13:21:18 +00002032 seq_putc(m, '\n');
2033}
2034
Ben Widawskyc0ab1ae92014-08-07 13:24:26 +01002035static int i915_dump_lrc(struct seq_file *m, void *unused)
2036{
David Weinehall36cdd012016-08-22 13:59:31 +03002037 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2038 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002039 struct intel_engine_cs *engine;
Chris Wilsone2efd132016-05-24 14:53:34 +01002040 struct i915_gem_context *ctx;
Akash Goel3b3f1652016-10-13 22:44:48 +05302041 enum intel_engine_id id;
Dave Gordonb4ac5af2016-03-24 11:20:38 +00002042 int ret;
Ben Widawskyc0ab1ae92014-08-07 13:24:26 +01002043
Michal Wajdeczko4f044a82017-09-19 19:38:44 +00002044 if (!i915_modparams.enable_execlists) {
Ben Widawskyc0ab1ae92014-08-07 13:24:26 +01002045 seq_printf(m, "Logical Ring Contexts are disabled\n");
2046 return 0;
2047 }
2048
2049 ret = mutex_lock_interruptible(&dev->struct_mutex);
2050 if (ret)
2051 return ret;
2052
Chris Wilson829a0af2017-06-20 12:05:45 +01002053 list_for_each_entry(ctx, &dev_priv->contexts.list, link)
Akash Goel3b3f1652016-10-13 22:44:48 +05302054 for_each_engine(engine, dev_priv, id)
Chris Wilson24f1d3c2016-04-28 09:56:53 +01002055 i915_dump_lrc_obj(m, ctx, engine);
Ben Widawskyc0ab1ae92014-08-07 13:24:26 +01002056
2057 mutex_unlock(&dev->struct_mutex);
2058
2059 return 0;
2060}
2061
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002062static const char *swizzle_string(unsigned swizzle)
2063{
Damien Lespiauaee56cf2013-06-24 22:59:49 +01002064 switch (swizzle) {
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002065 case I915_BIT_6_SWIZZLE_NONE:
2066 return "none";
2067 case I915_BIT_6_SWIZZLE_9:
2068 return "bit9";
2069 case I915_BIT_6_SWIZZLE_9_10:
2070 return "bit9/bit10";
2071 case I915_BIT_6_SWIZZLE_9_11:
2072 return "bit9/bit11";
2073 case I915_BIT_6_SWIZZLE_9_10_11:
2074 return "bit9/bit10/bit11";
2075 case I915_BIT_6_SWIZZLE_9_17:
2076 return "bit9/bit17";
2077 case I915_BIT_6_SWIZZLE_9_10_17:
2078 return "bit9/bit10/bit17";
2079 case I915_BIT_6_SWIZZLE_UNKNOWN:
Masanari Iida8a168ca2012-12-29 02:00:09 +09002080 return "unknown";
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002081 }
2082
2083 return "bug";
2084}
2085
2086static int i915_swizzle_info(struct seq_file *m, void *data)
2087{
David Weinehall36cdd012016-08-22 13:59:31 +03002088 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002089
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002090 intel_runtime_pm_get(dev_priv);
Daniel Vetter22bcfc62012-08-09 15:07:02 +02002091
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002092 seq_printf(m, "bit6 swizzle for X-tiling = %s\n",
2093 swizzle_string(dev_priv->mm.bit_6_swizzle_x));
2094 seq_printf(m, "bit6 swizzle for Y-tiling = %s\n",
2095 swizzle_string(dev_priv->mm.bit_6_swizzle_y));
2096
David Weinehall36cdd012016-08-22 13:59:31 +03002097 if (IS_GEN3(dev_priv) || IS_GEN4(dev_priv)) {
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002098 seq_printf(m, "DDC = 0x%08x\n",
2099 I915_READ(DCC));
Daniel Vetter656bfa32014-11-20 09:26:30 +01002100 seq_printf(m, "DDC2 = 0x%08x\n",
2101 I915_READ(DCC2));
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002102 seq_printf(m, "C0DRB3 = 0x%04x\n",
2103 I915_READ16(C0DRB3));
2104 seq_printf(m, "C1DRB3 = 0x%04x\n",
2105 I915_READ16(C1DRB3));
David Weinehall36cdd012016-08-22 13:59:31 +03002106 } else if (INTEL_GEN(dev_priv) >= 6) {
Daniel Vetter3fa7d232012-01-31 16:47:56 +01002107 seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n",
2108 I915_READ(MAD_DIMM_C0));
2109 seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n",
2110 I915_READ(MAD_DIMM_C1));
2111 seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n",
2112 I915_READ(MAD_DIMM_C2));
2113 seq_printf(m, "TILECTL = 0x%08x\n",
2114 I915_READ(TILECTL));
David Weinehall36cdd012016-08-22 13:59:31 +03002115 if (INTEL_GEN(dev_priv) >= 8)
Ben Widawsky9d3203e2013-11-02 21:07:14 -07002116 seq_printf(m, "GAMTARBMODE = 0x%08x\n",
2117 I915_READ(GAMTARBMODE));
2118 else
2119 seq_printf(m, "ARB_MODE = 0x%08x\n",
2120 I915_READ(ARB_MODE));
Daniel Vetter3fa7d232012-01-31 16:47:56 +01002121 seq_printf(m, "DISP_ARB_CTL = 0x%08x\n",
2122 I915_READ(DISP_ARB_CTL));
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002123 }
Daniel Vetter656bfa32014-11-20 09:26:30 +01002124
2125 if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES)
2126 seq_puts(m, "L-shaped memory detected\n");
2127
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002128 intel_runtime_pm_put(dev_priv);
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002129
2130 return 0;
2131}
2132
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002133static int per_file_ctx(int id, void *ptr, void *data)
2134{
Chris Wilsone2efd132016-05-24 14:53:34 +01002135 struct i915_gem_context *ctx = ptr;
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002136 struct seq_file *m = data;
Daniel Vetterae6c4802014-08-06 15:04:53 +02002137 struct i915_hw_ppgtt *ppgtt = ctx->ppgtt;
2138
2139 if (!ppgtt) {
2140 seq_printf(m, " no ppgtt for context %d\n",
2141 ctx->user_handle);
2142 return 0;
2143 }
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002144
Oscar Mateof83d6512014-05-22 14:13:38 +01002145 if (i915_gem_context_is_default(ctx))
2146 seq_puts(m, " default context:\n");
2147 else
Oscar Mateo821d66d2014-07-03 16:28:00 +01002148 seq_printf(m, " context %d:\n", ctx->user_handle);
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002149 ppgtt->debug_dump(ppgtt, m);
2150
2151 return 0;
2152}
2153
David Weinehall36cdd012016-08-22 13:59:31 +03002154static void gen8_ppgtt_info(struct seq_file *m,
2155 struct drm_i915_private *dev_priv)
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002156{
Ben Widawsky77df6772013-11-02 21:07:30 -07002157 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
Akash Goel3b3f1652016-10-13 22:44:48 +05302158 struct intel_engine_cs *engine;
2159 enum intel_engine_id id;
Dave Gordonb4ac5af2016-03-24 11:20:38 +00002160 int i;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002161
Ben Widawsky77df6772013-11-02 21:07:30 -07002162 if (!ppgtt)
2163 return;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002164
Akash Goel3b3f1652016-10-13 22:44:48 +05302165 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002166 seq_printf(m, "%s\n", engine->name);
Ben Widawsky77df6772013-11-02 21:07:30 -07002167 for (i = 0; i < 4; i++) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002168 u64 pdp = I915_READ(GEN8_RING_PDP_UDW(engine, i));
Ben Widawsky77df6772013-11-02 21:07:30 -07002169 pdp <<= 32;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002170 pdp |= I915_READ(GEN8_RING_PDP_LDW(engine, i));
Ville Syrjäläa2a5b152014-03-31 18:17:16 +03002171 seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp);
Ben Widawsky77df6772013-11-02 21:07:30 -07002172 }
2173 }
2174}
2175
David Weinehall36cdd012016-08-22 13:59:31 +03002176static void gen6_ppgtt_info(struct seq_file *m,
2177 struct drm_i915_private *dev_priv)
Ben Widawsky77df6772013-11-02 21:07:30 -07002178{
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002179 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +05302180 enum intel_engine_id id;
Ben Widawsky77df6772013-11-02 21:07:30 -07002181
Tvrtko Ursulin7e22dbb2016-05-10 10:57:06 +01002182 if (IS_GEN6(dev_priv))
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002183 seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE));
2184
Akash Goel3b3f1652016-10-13 22:44:48 +05302185 for_each_engine(engine, dev_priv, id) {
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002186 seq_printf(m, "%s\n", engine->name);
Tvrtko Ursulin7e22dbb2016-05-10 10:57:06 +01002187 if (IS_GEN7(dev_priv))
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002188 seq_printf(m, "GFX_MODE: 0x%08x\n",
2189 I915_READ(RING_MODE_GEN7(engine)));
2190 seq_printf(m, "PP_DIR_BASE: 0x%08x\n",
2191 I915_READ(RING_PP_DIR_BASE(engine)));
2192 seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n",
2193 I915_READ(RING_PP_DIR_BASE_READ(engine)));
2194 seq_printf(m, "PP_DIR_DCLV: 0x%08x\n",
2195 I915_READ(RING_PP_DIR_DCLV(engine)));
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002196 }
2197 if (dev_priv->mm.aliasing_ppgtt) {
2198 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
2199
Damien Lespiau267f0c92013-06-24 22:59:48 +01002200 seq_puts(m, "aliasing PPGTT:\n");
Mika Kuoppala44159dd2015-06-25 18:35:07 +03002201 seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd.base.ggtt_offset);
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002202
Ben Widawsky87d60b62013-12-06 14:11:29 -08002203 ppgtt->debug_dump(ppgtt, m);
Daniel Vetterae6c4802014-08-06 15:04:53 +02002204 }
Ben Widawsky1c60fef2013-12-06 14:11:30 -08002205
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002206 seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK));
Ben Widawsky77df6772013-11-02 21:07:30 -07002207}
2208
2209static int i915_ppgtt_info(struct seq_file *m, void *data)
2210{
David Weinehall36cdd012016-08-22 13:59:31 +03002211 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2212 struct drm_device *dev = &dev_priv->drm;
Michel Thierryea91e402015-07-29 17:23:57 +01002213 struct drm_file *file;
Chris Wilson637ee292016-08-22 14:28:20 +01002214 int ret;
Ben Widawsky77df6772013-11-02 21:07:30 -07002215
Chris Wilson637ee292016-08-22 14:28:20 +01002216 mutex_lock(&dev->filelist_mutex);
2217 ret = mutex_lock_interruptible(&dev->struct_mutex);
Ben Widawsky77df6772013-11-02 21:07:30 -07002218 if (ret)
Chris Wilson637ee292016-08-22 14:28:20 +01002219 goto out_unlock;
2220
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002221 intel_runtime_pm_get(dev_priv);
Ben Widawsky77df6772013-11-02 21:07:30 -07002222
David Weinehall36cdd012016-08-22 13:59:31 +03002223 if (INTEL_GEN(dev_priv) >= 8)
2224 gen8_ppgtt_info(m, dev_priv);
2225 else if (INTEL_GEN(dev_priv) >= 6)
2226 gen6_ppgtt_info(m, dev_priv);
Ben Widawsky77df6772013-11-02 21:07:30 -07002227
Michel Thierryea91e402015-07-29 17:23:57 +01002228 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
2229 struct drm_i915_file_private *file_priv = file->driver_priv;
Geliang Tang7cb5dff2015-09-25 03:58:11 -07002230 struct task_struct *task;
Michel Thierryea91e402015-07-29 17:23:57 +01002231
Geliang Tang7cb5dff2015-09-25 03:58:11 -07002232 task = get_pid_task(file->pid, PIDTYPE_PID);
Dan Carpenter06812762015-10-02 18:14:22 +03002233 if (!task) {
2234 ret = -ESRCH;
Chris Wilson637ee292016-08-22 14:28:20 +01002235 goto out_rpm;
Dan Carpenter06812762015-10-02 18:14:22 +03002236 }
Geliang Tang7cb5dff2015-09-25 03:58:11 -07002237 seq_printf(m, "\nproc: %s\n", task->comm);
2238 put_task_struct(task);
Michel Thierryea91e402015-07-29 17:23:57 +01002239 idr_for_each(&file_priv->context_idr, per_file_ctx,
2240 (void *)(unsigned long)m);
2241 }
2242
Chris Wilson637ee292016-08-22 14:28:20 +01002243out_rpm:
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002244 intel_runtime_pm_put(dev_priv);
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002245 mutex_unlock(&dev->struct_mutex);
Chris Wilson637ee292016-08-22 14:28:20 +01002246out_unlock:
2247 mutex_unlock(&dev->filelist_mutex);
Dan Carpenter06812762015-10-02 18:14:22 +03002248 return ret;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002249}
2250
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002251static int count_irq_waiters(struct drm_i915_private *i915)
2252{
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002253 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +05302254 enum intel_engine_id id;
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002255 int count = 0;
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002256
Akash Goel3b3f1652016-10-13 22:44:48 +05302257 for_each_engine(engine, i915, id)
Chris Wilson688e6c72016-07-01 17:23:15 +01002258 count += intel_engine_has_waiter(engine);
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002259
2260 return count;
2261}
2262
Chris Wilson7466c292016-08-15 09:49:33 +01002263static const char *rps_power_to_str(unsigned int power)
2264{
2265 static const char * const strings[] = {
2266 [LOW_POWER] = "low power",
2267 [BETWEEN] = "mixed",
2268 [HIGH_POWER] = "high power",
2269 };
2270
2271 if (power >= ARRAY_SIZE(strings) || !strings[power])
2272 return "unknown";
2273
2274 return strings[power];
2275}
2276
Chris Wilson1854d5c2015-04-07 16:20:32 +01002277static int i915_rps_boost_info(struct seq_file *m, void *data)
2278{
David Weinehall36cdd012016-08-22 13:59:31 +03002279 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2280 struct drm_device *dev = &dev_priv->drm;
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01002281 struct intel_rps *rps = &dev_priv->gt_pm.rps;
Chris Wilson1854d5c2015-04-07 16:20:32 +01002282 struct drm_file *file;
Chris Wilson1854d5c2015-04-07 16:20:32 +01002283
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01002284 seq_printf(m, "RPS enabled? %d\n", rps->enabled);
Chris Wilson28176ef2016-10-28 13:58:56 +01002285 seq_printf(m, "GPU busy? %s [%d requests]\n",
2286 yesno(dev_priv->gt.awake), dev_priv->gt.active_requests);
Chris Wilsonf5a4c672015-04-27 13:41:23 +01002287 seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv));
Chris Wilson7b92c1b2017-06-28 13:35:48 +01002288 seq_printf(m, "Boosts outstanding? %d\n",
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01002289 atomic_read(&rps->num_waiters));
Chris Wilson7466c292016-08-15 09:49:33 +01002290 seq_printf(m, "Frequency requested %d\n",
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01002291 intel_gpu_freq(dev_priv, rps->cur_freq));
Chris Wilson7466c292016-08-15 09:49:33 +01002292 seq_printf(m, " min hard:%d, soft:%d; max soft:%d, hard:%d\n",
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01002293 intel_gpu_freq(dev_priv, rps->min_freq),
2294 intel_gpu_freq(dev_priv, rps->min_freq_softlimit),
2295 intel_gpu_freq(dev_priv, rps->max_freq_softlimit),
2296 intel_gpu_freq(dev_priv, rps->max_freq));
Chris Wilson7466c292016-08-15 09:49:33 +01002297 seq_printf(m, " idle:%d, efficient:%d, boost:%d\n",
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01002298 intel_gpu_freq(dev_priv, rps->idle_freq),
2299 intel_gpu_freq(dev_priv, rps->efficient_freq),
2300 intel_gpu_freq(dev_priv, rps->boost_freq));
Daniel Vetter1d2ac402016-04-26 19:29:41 +02002301
2302 mutex_lock(&dev->filelist_mutex);
Chris Wilson1854d5c2015-04-07 16:20:32 +01002303 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
2304 struct drm_i915_file_private *file_priv = file->driver_priv;
2305 struct task_struct *task;
2306
2307 rcu_read_lock();
2308 task = pid_task(file->pid, PIDTYPE_PID);
Chris Wilson7b92c1b2017-06-28 13:35:48 +01002309 seq_printf(m, "%s [%d]: %d boosts\n",
Chris Wilson1854d5c2015-04-07 16:20:32 +01002310 task ? task->comm : "<unknown>",
2311 task ? task->pid : -1,
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01002312 atomic_read(&file_priv->rps_client.boosts));
Chris Wilson1854d5c2015-04-07 16:20:32 +01002313 rcu_read_unlock();
2314 }
Chris Wilson7b92c1b2017-06-28 13:35:48 +01002315 seq_printf(m, "Kernel (anonymous) boosts: %d\n",
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01002316 atomic_read(&rps->boosts));
Daniel Vetter1d2ac402016-04-26 19:29:41 +02002317 mutex_unlock(&dev->filelist_mutex);
Chris Wilson1854d5c2015-04-07 16:20:32 +01002318
Chris Wilson7466c292016-08-15 09:49:33 +01002319 if (INTEL_GEN(dev_priv) >= 6 &&
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01002320 rps->enabled &&
Chris Wilson28176ef2016-10-28 13:58:56 +01002321 dev_priv->gt.active_requests) {
Chris Wilson7466c292016-08-15 09:49:33 +01002322 u32 rpup, rpupei;
2323 u32 rpdown, rpdownei;
2324
2325 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
2326 rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK;
2327 rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK;
2328 rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK;
2329 rpdownei = I915_READ_FW(GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK;
2330 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
2331
2332 seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n",
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01002333 rps_power_to_str(rps->power));
Chris Wilson7466c292016-08-15 09:49:33 +01002334 seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n",
Chris Wilson23f4a282017-02-18 11:27:08 +00002335 rpup && rpupei ? 100 * rpup / rpupei : 0,
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01002336 rps->up_threshold);
Chris Wilson7466c292016-08-15 09:49:33 +01002337 seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n",
Chris Wilson23f4a282017-02-18 11:27:08 +00002338 rpdown && rpdownei ? 100 * rpdown / rpdownei : 0,
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01002339 rps->down_threshold);
Chris Wilson7466c292016-08-15 09:49:33 +01002340 } else {
2341 seq_puts(m, "\nRPS Autotuning inactive\n");
2342 }
2343
Chris Wilson8d3afd72015-05-21 21:01:47 +01002344 return 0;
Chris Wilson1854d5c2015-04-07 16:20:32 +01002345}
2346
Ben Widawsky63573eb2013-07-04 11:02:07 -07002347static int i915_llc(struct seq_file *m, void *data)
2348{
David Weinehall36cdd012016-08-22 13:59:31 +03002349 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Mika Kuoppala3accaf72016-04-13 17:26:43 +03002350 const bool edram = INTEL_GEN(dev_priv) > 8;
Ben Widawsky63573eb2013-07-04 11:02:07 -07002351
David Weinehall36cdd012016-08-22 13:59:31 +03002352 seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv)));
Mika Kuoppala3accaf72016-04-13 17:26:43 +03002353 seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC",
2354 intel_uncore_edram_size(dev_priv)/1024/1024);
Ben Widawsky63573eb2013-07-04 11:02:07 -07002355
2356 return 0;
2357}
2358
Anusha Srivatsa0509ead2017-01-18 08:05:56 -08002359static int i915_huc_load_status_info(struct seq_file *m, void *data)
2360{
2361 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Michal Wajdeczko56ffc742017-10-17 09:44:49 +00002362 struct drm_printer p;
Anusha Srivatsa0509ead2017-01-18 08:05:56 -08002363
2364 if (!HAS_HUC_UCODE(dev_priv))
2365 return 0;
2366
Michal Wajdeczko56ffc742017-10-17 09:44:49 +00002367 p = drm_seq_file_printer(m);
2368 intel_uc_fw_dump(&dev_priv->huc.fw, &p);
Anusha Srivatsa0509ead2017-01-18 08:05:56 -08002369
sagar.a.kamble@intel.com3582ad12017-02-03 13:58:33 +05302370 intel_runtime_pm_get(dev_priv);
Anusha Srivatsa0509ead2017-01-18 08:05:56 -08002371 seq_printf(m, "\nHuC status 0x%08x:\n", I915_READ(HUC_STATUS2));
sagar.a.kamble@intel.com3582ad12017-02-03 13:58:33 +05302372 intel_runtime_pm_put(dev_priv);
Anusha Srivatsa0509ead2017-01-18 08:05:56 -08002373
2374 return 0;
2375}
2376
Alex Daifdf5d352015-08-12 15:43:37 +01002377static int i915_guc_load_status_info(struct seq_file *m, void *data)
2378{
David Weinehall36cdd012016-08-22 13:59:31 +03002379 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Michal Wajdeczko56ffc742017-10-17 09:44:49 +00002380 struct drm_printer p;
Alex Daifdf5d352015-08-12 15:43:37 +01002381 u32 tmp, i;
2382
Joonas Lahtinen2d1fe072016-04-07 11:08:05 +03002383 if (!HAS_GUC_UCODE(dev_priv))
Alex Daifdf5d352015-08-12 15:43:37 +01002384 return 0;
2385
Michal Wajdeczko56ffc742017-10-17 09:44:49 +00002386 p = drm_seq_file_printer(m);
2387 intel_uc_fw_dump(&dev_priv->guc.fw, &p);
Alex Daifdf5d352015-08-12 15:43:37 +01002388
sagar.a.kamble@intel.com3582ad12017-02-03 13:58:33 +05302389 intel_runtime_pm_get(dev_priv);
2390
Alex Daifdf5d352015-08-12 15:43:37 +01002391 tmp = I915_READ(GUC_STATUS);
2392
2393 seq_printf(m, "\nGuC status 0x%08x:\n", tmp);
2394 seq_printf(m, "\tBootrom status = 0x%x\n",
2395 (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT);
2396 seq_printf(m, "\tuKernel status = 0x%x\n",
2397 (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT);
2398 seq_printf(m, "\tMIA Core status = 0x%x\n",
2399 (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT);
2400 seq_puts(m, "\nScratch registers:\n");
2401 for (i = 0; i < 16; i++)
2402 seq_printf(m, "\t%2d: \t0x%x\n", i, I915_READ(SOFT_SCRATCH(i)));
2403
sagar.a.kamble@intel.com3582ad12017-02-03 13:58:33 +05302404 intel_runtime_pm_put(dev_priv);
2405
Alex Daifdf5d352015-08-12 15:43:37 +01002406 return 0;
2407}
2408
Akash Goel5aa1ee42016-10-12 21:54:36 +05302409static void i915_guc_log_info(struct seq_file *m,
2410 struct drm_i915_private *dev_priv)
2411{
2412 struct intel_guc *guc = &dev_priv->guc;
2413
2414 seq_puts(m, "\nGuC logging stats:\n");
2415
2416 seq_printf(m, "\tISR: flush count %10u, overflow count %10u\n",
2417 guc->log.flush_count[GUC_ISR_LOG_BUFFER],
2418 guc->log.total_overflow_count[GUC_ISR_LOG_BUFFER]);
2419
2420 seq_printf(m, "\tDPC: flush count %10u, overflow count %10u\n",
2421 guc->log.flush_count[GUC_DPC_LOG_BUFFER],
2422 guc->log.total_overflow_count[GUC_DPC_LOG_BUFFER]);
2423
2424 seq_printf(m, "\tCRASH: flush count %10u, overflow count %10u\n",
2425 guc->log.flush_count[GUC_CRASH_DUMP_LOG_BUFFER],
2426 guc->log.total_overflow_count[GUC_CRASH_DUMP_LOG_BUFFER]);
2427
2428 seq_printf(m, "\tTotal flush interrupt count: %u\n",
2429 guc->log.flush_interrupt_count);
2430
2431 seq_printf(m, "\tCapture miss count: %u\n",
2432 guc->log.capture_miss_count);
2433}
2434
Dave Gordon8b417c22015-08-12 15:43:44 +01002435static void i915_guc_client_info(struct seq_file *m,
2436 struct drm_i915_private *dev_priv,
2437 struct i915_guc_client *client)
2438{
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00002439 struct intel_engine_cs *engine;
Dave Gordonc18468c2016-08-09 15:19:22 +01002440 enum intel_engine_id id;
Dave Gordon8b417c22015-08-12 15:43:44 +01002441 uint64_t tot = 0;
Dave Gordon8b417c22015-08-12 15:43:44 +01002442
Oscar Mateob09935a2017-03-22 10:39:53 -07002443 seq_printf(m, "\tPriority %d, GuC stage index: %u, PD offset 0x%x\n",
2444 client->priority, client->stage_id, client->proc_desc_offset);
Michał Winiarski59db36c2017-09-14 12:51:23 +02002445 seq_printf(m, "\tDoorbell id %d, offset: 0x%lx\n",
2446 client->doorbell_id, client->doorbell_offset);
Dave Gordon8b417c22015-08-12 15:43:44 +01002447
Akash Goel3b3f1652016-10-13 22:44:48 +05302448 for_each_engine(engine, dev_priv, id) {
Dave Gordonc18468c2016-08-09 15:19:22 +01002449 u64 submissions = client->submissions[id];
2450 tot += submissions;
Dave Gordon8b417c22015-08-12 15:43:44 +01002451 seq_printf(m, "\tSubmissions: %llu %s\n",
Dave Gordonc18468c2016-08-09 15:19:22 +01002452 submissions, engine->name);
Dave Gordon8b417c22015-08-12 15:43:44 +01002453 }
2454 seq_printf(m, "\tTotal: %llu\n", tot);
2455}
2456
Oscar Mateoa8b93702017-05-10 15:04:51 +00002457static bool check_guc_submission(struct seq_file *m)
Dave Gordon8b417c22015-08-12 15:43:44 +01002458{
David Weinehall36cdd012016-08-22 13:59:31 +03002459 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Chris Wilson334636c2016-11-29 12:10:20 +00002460 const struct intel_guc *guc = &dev_priv->guc;
Dave Gordon8b417c22015-08-12 15:43:44 +01002461
Chris Wilson334636c2016-11-29 12:10:20 +00002462 if (!guc->execbuf_client) {
2463 seq_printf(m, "GuC submission %s\n",
2464 HAS_GUC_SCHED(dev_priv) ?
2465 "disabled" :
2466 "not supported");
Oscar Mateoa8b93702017-05-10 15:04:51 +00002467 return false;
Chris Wilson334636c2016-11-29 12:10:20 +00002468 }
Dave Gordon8b417c22015-08-12 15:43:44 +01002469
Oscar Mateoa8b93702017-05-10 15:04:51 +00002470 return true;
2471}
2472
Dave Gordon8b417c22015-08-12 15:43:44 +01002473static int i915_guc_info(struct seq_file *m, void *data)
2474{
2475 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2476 const struct intel_guc *guc = &dev_priv->guc;
Dave Gordon8b417c22015-08-12 15:43:44 +01002477
Oscar Mateoa8b93702017-05-10 15:04:51 +00002478 if (!check_guc_submission(m))
Dave Gordon8b417c22015-08-12 15:43:44 +01002479 return 0;
Dave Gordon8b417c22015-08-12 15:43:44 +01002480
Dave Gordon9636f6d2016-06-13 17:57:28 +01002481 seq_printf(m, "Doorbell map:\n");
Joonas Lahtinenabddffd2017-03-22 10:39:44 -07002482 seq_printf(m, "\t%*pb\n", GUC_NUM_DOORBELLS, guc->doorbell_bitmap);
Chris Wilson334636c2016-11-29 12:10:20 +00002483 seq_printf(m, "Doorbell next cacheline: 0x%x\n\n", guc->db_cacheline);
Dave Gordon9636f6d2016-06-13 17:57:28 +01002484
Chris Wilson334636c2016-11-29 12:10:20 +00002485 seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client);
2486 i915_guc_client_info(m, dev_priv, guc->execbuf_client);
Dave Gordone12ab162017-10-26 16:17:37 +02002487 seq_printf(m, "\nGuC preempt client @ %p:\n", guc->preempt_client);
2488 i915_guc_client_info(m, dev_priv, guc->preempt_client);
Dave Gordon8b417c22015-08-12 15:43:44 +01002489
Akash Goel5aa1ee42016-10-12 21:54:36 +05302490 i915_guc_log_info(m, dev_priv);
2491
Dave Gordon8b417c22015-08-12 15:43:44 +01002492 /* Add more as required ... */
2493
2494 return 0;
2495}
2496
Oscar Mateoa8b93702017-05-10 15:04:51 +00002497static int i915_guc_stage_pool(struct seq_file *m, void *data)
Alex Dai4c7e77f2015-08-12 15:43:40 +01002498{
David Weinehall36cdd012016-08-22 13:59:31 +03002499 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Oscar Mateoa8b93702017-05-10 15:04:51 +00002500 const struct intel_guc *guc = &dev_priv->guc;
2501 struct guc_stage_desc *desc = guc->stage_desc_pool_vaddr;
2502 struct i915_guc_client *client = guc->execbuf_client;
2503 unsigned int tmp;
2504 int index;
Alex Dai4c7e77f2015-08-12 15:43:40 +01002505
Oscar Mateoa8b93702017-05-10 15:04:51 +00002506 if (!check_guc_submission(m))
Alex Dai4c7e77f2015-08-12 15:43:40 +01002507 return 0;
2508
Oscar Mateoa8b93702017-05-10 15:04:51 +00002509 for (index = 0; index < GUC_MAX_STAGE_DESCRIPTORS; index++, desc++) {
2510 struct intel_engine_cs *engine;
Alex Dai4c7e77f2015-08-12 15:43:40 +01002511
Oscar Mateoa8b93702017-05-10 15:04:51 +00002512 if (!(desc->attribute & GUC_STAGE_DESC_ATTR_ACTIVE))
2513 continue;
Alex Dai4c7e77f2015-08-12 15:43:40 +01002514
Oscar Mateoa8b93702017-05-10 15:04:51 +00002515 seq_printf(m, "GuC stage descriptor %u:\n", index);
2516 seq_printf(m, "\tIndex: %u\n", desc->stage_id);
2517 seq_printf(m, "\tAttribute: 0x%x\n", desc->attribute);
2518 seq_printf(m, "\tPriority: %d\n", desc->priority);
2519 seq_printf(m, "\tDoorbell id: %d\n", desc->db_id);
2520 seq_printf(m, "\tEngines used: 0x%x\n",
2521 desc->engines_used);
2522 seq_printf(m, "\tDoorbell trigger phy: 0x%llx, cpu: 0x%llx, uK: 0x%x\n",
2523 desc->db_trigger_phy,
2524 desc->db_trigger_cpu,
2525 desc->db_trigger_uk);
2526 seq_printf(m, "\tProcess descriptor: 0x%x\n",
2527 desc->process_desc);
Colin Ian King9a094852017-05-16 10:22:35 +01002528 seq_printf(m, "\tWorkqueue address: 0x%x, size: 0x%x\n",
Oscar Mateoa8b93702017-05-10 15:04:51 +00002529 desc->wq_addr, desc->wq_size);
2530 seq_putc(m, '\n');
2531
2532 for_each_engine_masked(engine, dev_priv, client->engines, tmp) {
2533 u32 guc_engine_id = engine->guc_id;
2534 struct guc_execlist_context *lrc =
2535 &desc->lrc[guc_engine_id];
2536
2537 seq_printf(m, "\t%s LRC:\n", engine->name);
2538 seq_printf(m, "\t\tContext desc: 0x%x\n",
2539 lrc->context_desc);
2540 seq_printf(m, "\t\tContext id: 0x%x\n", lrc->context_id);
2541 seq_printf(m, "\t\tLRCA: 0x%x\n", lrc->ring_lrca);
2542 seq_printf(m, "\t\tRing begin: 0x%x\n", lrc->ring_begin);
2543 seq_printf(m, "\t\tRing end: 0x%x\n", lrc->ring_end);
2544 seq_putc(m, '\n');
2545 }
Alex Dai4c7e77f2015-08-12 15:43:40 +01002546 }
2547
Oscar Mateoa8b93702017-05-10 15:04:51 +00002548 return 0;
2549}
2550
Alex Dai4c7e77f2015-08-12 15:43:40 +01002551static int i915_guc_log_dump(struct seq_file *m, void *data)
2552{
Daniele Ceraolo Spurioac58d2a2017-05-22 10:50:28 -07002553 struct drm_info_node *node = m->private;
2554 struct drm_i915_private *dev_priv = node_to_i915(node);
2555 bool dump_load_err = !!node->info_ent->data;
2556 struct drm_i915_gem_object *obj = NULL;
2557 u32 *log;
2558 int i = 0;
Alex Dai4c7e77f2015-08-12 15:43:40 +01002559
Daniele Ceraolo Spurioac58d2a2017-05-22 10:50:28 -07002560 if (dump_load_err)
2561 obj = dev_priv->guc.load_err_log;
2562 else if (dev_priv->guc.log.vma)
2563 obj = dev_priv->guc.log.vma->obj;
2564
2565 if (!obj)
Alex Dai4c7e77f2015-08-12 15:43:40 +01002566 return 0;
2567
Daniele Ceraolo Spurioac58d2a2017-05-22 10:50:28 -07002568 log = i915_gem_object_pin_map(obj, I915_MAP_WC);
2569 if (IS_ERR(log)) {
2570 DRM_DEBUG("Failed to pin object\n");
2571 seq_puts(m, "(log data unaccessible)\n");
2572 return PTR_ERR(log);
Alex Dai4c7e77f2015-08-12 15:43:40 +01002573 }
2574
Daniele Ceraolo Spurioac58d2a2017-05-22 10:50:28 -07002575 for (i = 0; i < obj->base.size / sizeof(u32); i += 4)
2576 seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n",
2577 *(log + i), *(log + i + 1),
2578 *(log + i + 2), *(log + i + 3));
2579
Alex Dai4c7e77f2015-08-12 15:43:40 +01002580 seq_putc(m, '\n');
2581
Daniele Ceraolo Spurioac58d2a2017-05-22 10:50:28 -07002582 i915_gem_object_unpin_map(obj);
2583
Alex Dai4c7e77f2015-08-12 15:43:40 +01002584 return 0;
2585}
2586
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05302587static int i915_guc_log_control_get(void *data, u64 *val)
2588{
Chris Wilsonbcc36d82017-04-07 20:42:20 +01002589 struct drm_i915_private *dev_priv = data;
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05302590
2591 if (!dev_priv->guc.log.vma)
2592 return -EINVAL;
2593
Michal Wajdeczko4f044a82017-09-19 19:38:44 +00002594 *val = i915_modparams.guc_log_level;
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05302595
2596 return 0;
2597}
2598
2599static int i915_guc_log_control_set(void *data, u64 val)
2600{
Chris Wilsonbcc36d82017-04-07 20:42:20 +01002601 struct drm_i915_private *dev_priv = data;
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05302602 int ret;
2603
2604 if (!dev_priv->guc.log.vma)
2605 return -EINVAL;
2606
Chris Wilsonbcc36d82017-04-07 20:42:20 +01002607 ret = mutex_lock_interruptible(&dev_priv->drm.struct_mutex);
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05302608 if (ret)
2609 return ret;
2610
2611 intel_runtime_pm_get(dev_priv);
2612 ret = i915_guc_log_control(dev_priv, val);
2613 intel_runtime_pm_put(dev_priv);
2614
Chris Wilsonbcc36d82017-04-07 20:42:20 +01002615 mutex_unlock(&dev_priv->drm.struct_mutex);
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05302616 return ret;
2617}
2618
2619DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_control_fops,
2620 i915_guc_log_control_get, i915_guc_log_control_set,
2621 "%lld\n");
2622
Chris Wilsonb86bef202017-01-16 13:06:21 +00002623static const char *psr2_live_status(u32 val)
2624{
2625 static const char * const live_status[] = {
2626 "IDLE",
2627 "CAPTURE",
2628 "CAPTURE_FS",
2629 "SLEEP",
2630 "BUFON_FW",
2631 "ML_UP",
2632 "SU_STANDBY",
2633 "FAST_SLEEP",
2634 "DEEP_SLEEP",
2635 "BUF_ON",
2636 "TG_ON"
2637 };
2638
2639 val = (val & EDP_PSR2_STATUS_STATE_MASK) >> EDP_PSR2_STATUS_STATE_SHIFT;
2640 if (val < ARRAY_SIZE(live_status))
2641 return live_status[val];
2642
2643 return "unknown";
2644}
2645
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002646static int i915_edp_psr_status(struct seq_file *m, void *data)
2647{
David Weinehall36cdd012016-08-22 13:59:31 +03002648 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Rodrigo Vivia031d702013-10-03 16:15:06 -03002649 u32 psrperf = 0;
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002650 u32 stat[3];
2651 enum pipe pipe;
Rodrigo Vivia031d702013-10-03 16:15:06 -03002652 bool enabled = false;
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002653
David Weinehall36cdd012016-08-22 13:59:31 +03002654 if (!HAS_PSR(dev_priv)) {
Damien Lespiau3553a8e2015-03-09 14:17:58 +00002655 seq_puts(m, "PSR not supported\n");
2656 return 0;
2657 }
2658
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002659 intel_runtime_pm_get(dev_priv);
2660
Daniel Vetterfa128fa2014-07-11 10:30:17 -07002661 mutex_lock(&dev_priv->psr.lock);
Rodrigo Vivia031d702013-10-03 16:15:06 -03002662 seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support));
2663 seq_printf(m, "Source_OK: %s\n", yesno(dev_priv->psr.source_ok));
Daniel Vetter2807cf62014-07-11 10:30:11 -07002664 seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled));
Rodrigo Vivi5755c782014-06-12 10:16:45 -07002665 seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active));
Daniel Vetterfa128fa2014-07-11 10:30:17 -07002666 seq_printf(m, "Busy frontbuffer bits: 0x%03x\n",
2667 dev_priv->psr.busy_frontbuffer_bits);
2668 seq_printf(m, "Re-enable work scheduled: %s\n",
2669 yesno(work_busy(&dev_priv->psr.work.work)));
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002670
Nagaraju, Vathsala7e3eb592016-12-09 23:42:09 +05302671 if (HAS_DDI(dev_priv)) {
2672 if (dev_priv->psr.psr2_support)
2673 enabled = I915_READ(EDP_PSR2_CTL) & EDP_PSR2_ENABLE;
2674 else
2675 enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE;
2676 } else {
Damien Lespiau3553a8e2015-03-09 14:17:58 +00002677 for_each_pipe(dev_priv, pipe) {
Chris Wilson9c870d02016-10-24 13:42:15 +01002678 enum transcoder cpu_transcoder =
2679 intel_pipe_to_cpu_transcoder(dev_priv, pipe);
2680 enum intel_display_power_domain power_domain;
2681
2682 power_domain = POWER_DOMAIN_TRANSCODER(cpu_transcoder);
2683 if (!intel_display_power_get_if_enabled(dev_priv,
2684 power_domain))
2685 continue;
2686
Damien Lespiau3553a8e2015-03-09 14:17:58 +00002687 stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) &
2688 VLV_EDP_PSR_CURR_STATE_MASK;
2689 if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) ||
2690 (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE))
2691 enabled = true;
Chris Wilson9c870d02016-10-24 13:42:15 +01002692
2693 intel_display_power_put(dev_priv, power_domain);
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002694 }
2695 }
Rodrigo Vivi60e5ffe2016-02-01 12:02:07 -08002696
2697 seq_printf(m, "Main link in standby mode: %s\n",
2698 yesno(dev_priv->psr.link_standby));
2699
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002700 seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled));
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002701
David Weinehall36cdd012016-08-22 13:59:31 +03002702 if (!HAS_DDI(dev_priv))
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002703 for_each_pipe(dev_priv, pipe) {
2704 if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) ||
2705 (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE))
2706 seq_printf(m, " pipe %c", pipe_name(pipe));
2707 }
2708 seq_puts(m, "\n");
2709
Rodrigo Vivi05eec3c2015-11-23 14:16:40 -08002710 /*
2711 * VLV/CHV PSR has no kind of performance counter
2712 * SKL+ Perf counter is reset to 0 everytime DC state is entered
2713 */
David Weinehall36cdd012016-08-22 13:59:31 +03002714 if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
Ville Syrjälä443a3892015-11-11 20:34:15 +02002715 psrperf = I915_READ(EDP_PSR_PERF_CNT) &
Rodrigo Vivia031d702013-10-03 16:15:06 -03002716 EDP_PSR_PERF_CNT_MASK;
Rodrigo Vivia6cbdb82014-11-14 08:52:40 -08002717
2718 seq_printf(m, "Performance_Counter: %u\n", psrperf);
2719 }
Nagaraju, Vathsala6ba1f9e2017-01-06 22:02:32 +05302720 if (dev_priv->psr.psr2_support) {
Chris Wilsonb86bef202017-01-16 13:06:21 +00002721 u32 psr2 = I915_READ(EDP_PSR2_STATUS_CTL);
Nagaraju, Vathsala6ba1f9e2017-01-06 22:02:32 +05302722
Chris Wilsonb86bef202017-01-16 13:06:21 +00002723 seq_printf(m, "EDP_PSR2_STATUS_CTL: %x [%s]\n",
2724 psr2, psr2_live_status(psr2));
Nagaraju, Vathsala6ba1f9e2017-01-06 22:02:32 +05302725 }
Daniel Vetterfa128fa2014-07-11 10:30:17 -07002726 mutex_unlock(&dev_priv->psr.lock);
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002727
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02002728 intel_runtime_pm_put(dev_priv);
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002729 return 0;
2730}
2731
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002732static int i915_sink_crc(struct seq_file *m, void *data)
2733{
David Weinehall36cdd012016-08-22 13:59:31 +03002734 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2735 struct drm_device *dev = &dev_priv->drm;
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002736 struct intel_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01002737 struct drm_connector_list_iter conn_iter;
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002738 struct intel_dp *intel_dp = NULL;
2739 int ret;
2740 u8 crc[6];
2741
2742 drm_modeset_lock_all(dev);
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01002743 drm_connector_list_iter_begin(dev, &conn_iter);
2744 for_each_intel_connector_iter(connector, &conn_iter) {
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002745 struct drm_crtc *crtc;
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002746
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002747 if (!connector->base.state->best_encoder)
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002748 continue;
2749
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002750 crtc = connector->base.state->crtc;
2751 if (!crtc->state->active)
Paulo Zanonib6ae3c72014-02-13 17:51:33 -02002752 continue;
2753
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002754 if (connector->base.connector_type != DRM_MODE_CONNECTOR_eDP)
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002755 continue;
2756
Maarten Lankhorst26c17cf2016-06-20 15:57:38 +02002757 intel_dp = enc_to_intel_dp(connector->base.state->best_encoder);
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002758
2759 ret = intel_dp_sink_crc(intel_dp, crc);
2760 if (ret)
2761 goto out;
2762
2763 seq_printf(m, "%02x%02x%02x%02x%02x%02x\n",
2764 crc[0], crc[1], crc[2],
2765 crc[3], crc[4], crc[5]);
2766 goto out;
2767 }
2768 ret = -ENODEV;
2769out:
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01002770 drm_connector_list_iter_end(&conn_iter);
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002771 drm_modeset_unlock_all(dev);
2772 return ret;
2773}
2774
Jesse Barnesec013e72013-08-20 10:29:23 +01002775static int i915_energy_uJ(struct seq_file *m, void *data)
2776{
David Weinehall36cdd012016-08-22 13:59:31 +03002777 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Gabriel Krisman Bertazid38014e2017-07-26 02:30:16 -03002778 unsigned long long power;
Jesse Barnesec013e72013-08-20 10:29:23 +01002779 u32 units;
2780
David Weinehall36cdd012016-08-22 13:59:31 +03002781 if (INTEL_GEN(dev_priv) < 6)
Jesse Barnesec013e72013-08-20 10:29:23 +01002782 return -ENODEV;
2783
Paulo Zanoni36623ef2014-02-21 13:52:23 -03002784 intel_runtime_pm_get(dev_priv);
2785
Gabriel Krisman Bertazid38014e2017-07-26 02:30:16 -03002786 if (rdmsrl_safe(MSR_RAPL_POWER_UNIT, &power)) {
2787 intel_runtime_pm_put(dev_priv);
2788 return -ENODEV;
2789 }
2790
2791 units = (power & 0x1f00) >> 8;
Jesse Barnesec013e72013-08-20 10:29:23 +01002792 power = I915_READ(MCH_SECP_NRG_STTS);
Gabriel Krisman Bertazid38014e2017-07-26 02:30:16 -03002793 power = (1000000 * power) >> units; /* convert to uJ */
Jesse Barnesec013e72013-08-20 10:29:23 +01002794
Paulo Zanoni36623ef2014-02-21 13:52:23 -03002795 intel_runtime_pm_put(dev_priv);
2796
Gabriel Krisman Bertazid38014e2017-07-26 02:30:16 -03002797 seq_printf(m, "%llu", power);
Paulo Zanoni371db662013-08-19 13:18:10 -03002798
2799 return 0;
2800}
2801
Damien Lespiau6455c872015-06-04 18:23:57 +01002802static int i915_runtime_pm_status(struct seq_file *m, void *unused)
Paulo Zanoni371db662013-08-19 13:18:10 -03002803{
David Weinehall36cdd012016-08-22 13:59:31 +03002804 struct drm_i915_private *dev_priv = node_to_i915(m->private);
David Weinehall52a05c32016-08-22 13:32:44 +03002805 struct pci_dev *pdev = dev_priv->drm.pdev;
Paulo Zanoni371db662013-08-19 13:18:10 -03002806
Chris Wilsona156e642016-04-03 14:14:21 +01002807 if (!HAS_RUNTIME_PM(dev_priv))
2808 seq_puts(m, "Runtime power management not supported\n");
Paulo Zanoni371db662013-08-19 13:18:10 -03002809
Chris Wilson67d97da2016-07-04 08:08:31 +01002810 seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->gt.awake));
Paulo Zanoni371db662013-08-19 13:18:10 -03002811 seq_printf(m, "IRQs disabled: %s\n",
Jesse Barnes9df7575f2014-06-20 09:29:20 -07002812 yesno(!intel_irqs_enabled(dev_priv)));
Chris Wilson0d804182015-06-15 12:52:28 +01002813#ifdef CONFIG_PM
Damien Lespiaua6aaec82015-06-04 18:23:58 +01002814 seq_printf(m, "Usage count: %d\n",
David Weinehall36cdd012016-08-22 13:59:31 +03002815 atomic_read(&dev_priv->drm.dev->power.usage_count));
Chris Wilson0d804182015-06-15 12:52:28 +01002816#else
2817 seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n");
2818#endif
Chris Wilsona156e642016-04-03 14:14:21 +01002819 seq_printf(m, "PCI device power state: %s [%d]\n",
David Weinehall52a05c32016-08-22 13:32:44 +03002820 pci_power_name(pdev->current_state),
2821 pdev->current_state);
Paulo Zanoni371db662013-08-19 13:18:10 -03002822
Jesse Barnesec013e72013-08-20 10:29:23 +01002823 return 0;
2824}
2825
Imre Deak1da51582013-11-25 17:15:35 +02002826static int i915_power_domain_info(struct seq_file *m, void *unused)
2827{
David Weinehall36cdd012016-08-22 13:59:31 +03002828 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Imre Deak1da51582013-11-25 17:15:35 +02002829 struct i915_power_domains *power_domains = &dev_priv->power_domains;
2830 int i;
2831
2832 mutex_lock(&power_domains->lock);
2833
2834 seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count");
2835 for (i = 0; i < power_domains->power_well_count; i++) {
2836 struct i915_power_well *power_well;
2837 enum intel_display_power_domain power_domain;
2838
2839 power_well = &power_domains->power_wells[i];
2840 seq_printf(m, "%-25s %d\n", power_well->name,
2841 power_well->count);
2842
Joonas Lahtinen8385c2e2017-02-08 15:12:10 +02002843 for_each_power_domain(power_domain, power_well->domains)
Imre Deak1da51582013-11-25 17:15:35 +02002844 seq_printf(m, " %-23s %d\n",
Daniel Stone9895ad02015-11-20 15:55:33 +00002845 intel_display_power_domain_str(power_domain),
Imre Deak1da51582013-11-25 17:15:35 +02002846 power_domains->domain_use_count[power_domain]);
Imre Deak1da51582013-11-25 17:15:35 +02002847 }
2848
2849 mutex_unlock(&power_domains->lock);
2850
2851 return 0;
2852}
2853
Damien Lespiaub7cec662015-10-27 14:47:01 +02002854static int i915_dmc_info(struct seq_file *m, void *unused)
2855{
David Weinehall36cdd012016-08-22 13:59:31 +03002856 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Damien Lespiaub7cec662015-10-27 14:47:01 +02002857 struct intel_csr *csr;
2858
David Weinehall36cdd012016-08-22 13:59:31 +03002859 if (!HAS_CSR(dev_priv)) {
Damien Lespiaub7cec662015-10-27 14:47:01 +02002860 seq_puts(m, "not supported\n");
2861 return 0;
2862 }
2863
2864 csr = &dev_priv->csr;
2865
Mika Kuoppala6fb403d2015-10-30 17:54:47 +02002866 intel_runtime_pm_get(dev_priv);
2867
Damien Lespiaub7cec662015-10-27 14:47:01 +02002868 seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL));
2869 seq_printf(m, "path: %s\n", csr->fw_path);
2870
2871 if (!csr->dmc_payload)
Mika Kuoppala6fb403d2015-10-30 17:54:47 +02002872 goto out;
Damien Lespiaub7cec662015-10-27 14:47:01 +02002873
2874 seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version),
2875 CSR_VERSION_MINOR(csr->version));
2876
Mika Kuoppala48de5682017-05-09 13:05:22 +03002877 if (IS_KABYLAKE(dev_priv) ||
2878 (IS_SKYLAKE(dev_priv) && csr->version >= CSR_VERSION(1, 6))) {
Damien Lespiau83372062015-10-30 17:53:32 +02002879 seq_printf(m, "DC3 -> DC5 count: %d\n",
2880 I915_READ(SKL_CSR_DC3_DC5_COUNT));
2881 seq_printf(m, "DC5 -> DC6 count: %d\n",
2882 I915_READ(SKL_CSR_DC5_DC6_COUNT));
David Weinehall36cdd012016-08-22 13:59:31 +03002883 } else if (IS_BROXTON(dev_priv) && csr->version >= CSR_VERSION(1, 4)) {
Mika Kuoppala16e11b92015-10-27 14:47:03 +02002884 seq_printf(m, "DC3 -> DC5 count: %d\n",
2885 I915_READ(BXT_CSR_DC3_DC5_COUNT));
Damien Lespiau83372062015-10-30 17:53:32 +02002886 }
2887
Mika Kuoppala6fb403d2015-10-30 17:54:47 +02002888out:
2889 seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0)));
2890 seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE));
2891 seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL));
2892
Damien Lespiau83372062015-10-30 17:53:32 +02002893 intel_runtime_pm_put(dev_priv);
2894
Damien Lespiaub7cec662015-10-27 14:47:01 +02002895 return 0;
2896}
2897
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002898static void intel_seq_print_mode(struct seq_file *m, int tabs,
2899 struct drm_display_mode *mode)
2900{
2901 int i;
2902
2903 for (i = 0; i < tabs; i++)
2904 seq_putc(m, '\t');
2905
2906 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",
2907 mode->base.id, mode->name,
2908 mode->vrefresh, mode->clock,
2909 mode->hdisplay, mode->hsync_start,
2910 mode->hsync_end, mode->htotal,
2911 mode->vdisplay, mode->vsync_start,
2912 mode->vsync_end, mode->vtotal,
2913 mode->type, mode->flags);
2914}
2915
2916static void intel_encoder_info(struct seq_file *m,
2917 struct intel_crtc *intel_crtc,
2918 struct intel_encoder *intel_encoder)
2919{
David Weinehall36cdd012016-08-22 13:59:31 +03002920 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2921 struct drm_device *dev = &dev_priv->drm;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002922 struct drm_crtc *crtc = &intel_crtc->base;
2923 struct intel_connector *intel_connector;
2924 struct drm_encoder *encoder;
2925
2926 encoder = &intel_encoder->base;
2927 seq_printf(m, "\tencoder %d: type: %s, connectors:\n",
Jani Nikula8e329a032014-06-03 14:56:21 +03002928 encoder->base.id, encoder->name);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002929 for_each_connector_on_encoder(dev, encoder, intel_connector) {
2930 struct drm_connector *connector = &intel_connector->base;
2931 seq_printf(m, "\t\tconnector %d: type: %s, status: %s",
2932 connector->base.id,
Jani Nikulac23cc412014-06-03 14:56:17 +03002933 connector->name,
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002934 drm_get_connector_status_name(connector->status));
2935 if (connector->status == connector_status_connected) {
2936 struct drm_display_mode *mode = &crtc->mode;
2937 seq_printf(m, ", mode:\n");
2938 intel_seq_print_mode(m, 2, mode);
2939 } else {
2940 seq_putc(m, '\n');
2941 }
2942 }
2943}
2944
2945static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc)
2946{
David Weinehall36cdd012016-08-22 13:59:31 +03002947 struct drm_i915_private *dev_priv = node_to_i915(m->private);
2948 struct drm_device *dev = &dev_priv->drm;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002949 struct drm_crtc *crtc = &intel_crtc->base;
2950 struct intel_encoder *intel_encoder;
Maarten Lankhorst23a48d52015-09-10 16:07:57 +02002951 struct drm_plane_state *plane_state = crtc->primary->state;
2952 struct drm_framebuffer *fb = plane_state->fb;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002953
Maarten Lankhorst23a48d52015-09-10 16:07:57 +02002954 if (fb)
Matt Roper5aa8a932014-06-16 10:12:55 -07002955 seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n",
Maarten Lankhorst23a48d52015-09-10 16:07:57 +02002956 fb->base.id, plane_state->src_x >> 16,
2957 plane_state->src_y >> 16, fb->width, fb->height);
Matt Roper5aa8a932014-06-16 10:12:55 -07002958 else
2959 seq_puts(m, "\tprimary plane disabled\n");
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002960 for_each_encoder_on_crtc(dev, crtc, intel_encoder)
2961 intel_encoder_info(m, intel_crtc, intel_encoder);
2962}
2963
2964static void intel_panel_info(struct seq_file *m, struct intel_panel *panel)
2965{
2966 struct drm_display_mode *mode = panel->fixed_mode;
2967
2968 seq_printf(m, "\tfixed mode:\n");
2969 intel_seq_print_mode(m, 2, mode);
2970}
2971
2972static void intel_dp_info(struct seq_file *m,
2973 struct intel_connector *intel_connector)
2974{
2975 struct intel_encoder *intel_encoder = intel_connector->encoder;
2976 struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base);
2977
2978 seq_printf(m, "\tDPCD rev: %x\n", intel_dp->dpcd[DP_DPCD_REV]);
Jani Nikula742f4912015-09-03 11:16:09 +03002979 seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio));
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02002980 if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP)
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002981 intel_panel_info(m, &intel_connector->panel);
Mika Kahola80209e52016-09-09 14:10:57 +03002982
2983 drm_dp_downstream_debug(m, intel_dp->dpcd, intel_dp->downstream_ports,
2984 &intel_dp->aux);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002985}
2986
Libin Yang9a148a92016-11-28 20:07:05 +08002987static void intel_dp_mst_info(struct seq_file *m,
2988 struct intel_connector *intel_connector)
2989{
2990 struct intel_encoder *intel_encoder = intel_connector->encoder;
2991 struct intel_dp_mst_encoder *intel_mst =
2992 enc_to_mst(&intel_encoder->base);
2993 struct intel_digital_port *intel_dig_port = intel_mst->primary;
2994 struct intel_dp *intel_dp = &intel_dig_port->dp;
2995 bool has_audio = drm_dp_mst_port_has_audio(&intel_dp->mst_mgr,
2996 intel_connector->port);
2997
2998 seq_printf(m, "\taudio support: %s\n", yesno(has_audio));
2999}
3000
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003001static void intel_hdmi_info(struct seq_file *m,
3002 struct intel_connector *intel_connector)
3003{
3004 struct intel_encoder *intel_encoder = intel_connector->encoder;
3005 struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base);
3006
Jani Nikula742f4912015-09-03 11:16:09 +03003007 seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio));
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003008}
3009
3010static void intel_lvds_info(struct seq_file *m,
3011 struct intel_connector *intel_connector)
3012{
3013 intel_panel_info(m, &intel_connector->panel);
3014}
3015
3016static void intel_connector_info(struct seq_file *m,
3017 struct drm_connector *connector)
3018{
3019 struct intel_connector *intel_connector = to_intel_connector(connector);
3020 struct intel_encoder *intel_encoder = intel_connector->encoder;
Jesse Barnesf103fc72014-02-20 12:39:57 -08003021 struct drm_display_mode *mode;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003022
3023 seq_printf(m, "connector %d: type %s, status: %s\n",
Jani Nikulac23cc412014-06-03 14:56:17 +03003024 connector->base.id, connector->name,
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003025 drm_get_connector_status_name(connector->status));
3026 if (connector->status == connector_status_connected) {
3027 seq_printf(m, "\tname: %s\n", connector->display_info.name);
3028 seq_printf(m, "\tphysical dimensions: %dx%dmm\n",
3029 connector->display_info.width_mm,
3030 connector->display_info.height_mm);
3031 seq_printf(m, "\tsubpixel order: %s\n",
3032 drm_get_subpixel_order_name(connector->display_info.subpixel_order));
3033 seq_printf(m, "\tCEA rev: %d\n",
3034 connector->display_info.cea_rev);
3035 }
Maarten Lankhorstee648a72016-06-21 12:00:38 +02003036
Maarten Lankhorst77d1f612017-06-26 10:33:49 +02003037 if (!intel_encoder)
Maarten Lankhorstee648a72016-06-21 12:00:38 +02003038 return;
3039
3040 switch (connector->connector_type) {
3041 case DRM_MODE_CONNECTOR_DisplayPort:
3042 case DRM_MODE_CONNECTOR_eDP:
Libin Yang9a148a92016-11-28 20:07:05 +08003043 if (intel_encoder->type == INTEL_OUTPUT_DP_MST)
3044 intel_dp_mst_info(m, intel_connector);
3045 else
3046 intel_dp_info(m, intel_connector);
Maarten Lankhorstee648a72016-06-21 12:00:38 +02003047 break;
3048 case DRM_MODE_CONNECTOR_LVDS:
3049 if (intel_encoder->type == INTEL_OUTPUT_LVDS)
Dave Airlie36cd7442014-05-02 13:44:18 +10003050 intel_lvds_info(m, intel_connector);
Maarten Lankhorstee648a72016-06-21 12:00:38 +02003051 break;
3052 case DRM_MODE_CONNECTOR_HDMIA:
3053 if (intel_encoder->type == INTEL_OUTPUT_HDMI ||
Ville Syrjälä7e732ca2017-10-27 22:31:24 +03003054 intel_encoder->type == INTEL_OUTPUT_DDI)
Maarten Lankhorstee648a72016-06-21 12:00:38 +02003055 intel_hdmi_info(m, intel_connector);
3056 break;
3057 default:
3058 break;
Dave Airlie36cd7442014-05-02 13:44:18 +10003059 }
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003060
Jesse Barnesf103fc72014-02-20 12:39:57 -08003061 seq_printf(m, "\tmodes:\n");
3062 list_for_each_entry(mode, &connector->modes, head)
3063 intel_seq_print_mode(m, 2, mode);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003064}
3065
Robert Fekete3abc4e02015-10-27 16:58:32 +01003066static const char *plane_type(enum drm_plane_type type)
3067{
3068 switch (type) {
3069 case DRM_PLANE_TYPE_OVERLAY:
3070 return "OVL";
3071 case DRM_PLANE_TYPE_PRIMARY:
3072 return "PRI";
3073 case DRM_PLANE_TYPE_CURSOR:
3074 return "CUR";
3075 /*
3076 * Deliberately omitting default: to generate compiler warnings
3077 * when a new drm_plane_type gets added.
3078 */
3079 }
3080
3081 return "unknown";
3082}
3083
3084static const char *plane_rotation(unsigned int rotation)
3085{
3086 static char buf[48];
3087 /*
Robert Fossc2c446a2017-05-19 16:50:17 -04003088 * According to doc only one DRM_MODE_ROTATE_ is allowed but this
Robert Fekete3abc4e02015-10-27 16:58:32 +01003089 * will print them all to visualize if the values are misused
3090 */
3091 snprintf(buf, sizeof(buf),
3092 "%s%s%s%s%s%s(0x%08x)",
Robert Fossc2c446a2017-05-19 16:50:17 -04003093 (rotation & DRM_MODE_ROTATE_0) ? "0 " : "",
3094 (rotation & DRM_MODE_ROTATE_90) ? "90 " : "",
3095 (rotation & DRM_MODE_ROTATE_180) ? "180 " : "",
3096 (rotation & DRM_MODE_ROTATE_270) ? "270 " : "",
3097 (rotation & DRM_MODE_REFLECT_X) ? "FLIPX " : "",
3098 (rotation & DRM_MODE_REFLECT_Y) ? "FLIPY " : "",
Robert Fekete3abc4e02015-10-27 16:58:32 +01003099 rotation);
3100
3101 return buf;
3102}
3103
3104static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc)
3105{
David Weinehall36cdd012016-08-22 13:59:31 +03003106 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3107 struct drm_device *dev = &dev_priv->drm;
Robert Fekete3abc4e02015-10-27 16:58:32 +01003108 struct intel_plane *intel_plane;
3109
3110 for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {
3111 struct drm_plane_state *state;
3112 struct drm_plane *plane = &intel_plane->base;
Eric Engestromb3c11ac2016-11-12 01:12:56 +00003113 struct drm_format_name_buf format_name;
Robert Fekete3abc4e02015-10-27 16:58:32 +01003114
3115 if (!plane->state) {
3116 seq_puts(m, "plane->state is NULL!\n");
3117 continue;
3118 }
3119
3120 state = plane->state;
3121
Eric Engestrom90844f02016-08-15 01:02:38 +01003122 if (state->fb) {
Ville Syrjälä438b74a2016-12-14 23:32:55 +02003123 drm_get_format_name(state->fb->format->format,
3124 &format_name);
Eric Engestrom90844f02016-08-15 01:02:38 +01003125 } else {
Eric Engestromb3c11ac2016-11-12 01:12:56 +00003126 sprintf(format_name.str, "N/A");
Eric Engestrom90844f02016-08-15 01:02:38 +01003127 }
3128
Robert Fekete3abc4e02015-10-27 16:58:32 +01003129 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",
3130 plane->base.id,
3131 plane_type(intel_plane->base.type),
3132 state->crtc_x, state->crtc_y,
3133 state->crtc_w, state->crtc_h,
3134 (state->src_x >> 16),
3135 ((state->src_x & 0xffff) * 15625) >> 10,
3136 (state->src_y >> 16),
3137 ((state->src_y & 0xffff) * 15625) >> 10,
3138 (state->src_w >> 16),
3139 ((state->src_w & 0xffff) * 15625) >> 10,
3140 (state->src_h >> 16),
3141 ((state->src_h & 0xffff) * 15625) >> 10,
Eric Engestromb3c11ac2016-11-12 01:12:56 +00003142 format_name.str,
Robert Fekete3abc4e02015-10-27 16:58:32 +01003143 plane_rotation(state->rotation));
3144 }
3145}
3146
3147static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc)
3148{
3149 struct intel_crtc_state *pipe_config;
3150 int num_scalers = intel_crtc->num_scalers;
3151 int i;
3152
3153 pipe_config = to_intel_crtc_state(intel_crtc->base.state);
3154
3155 /* Not all platformas have a scaler */
3156 if (num_scalers) {
3157 seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d",
3158 num_scalers,
3159 pipe_config->scaler_state.scaler_users,
3160 pipe_config->scaler_state.scaler_id);
3161
A.Sunil Kamath58415912016-11-20 23:20:26 +05303162 for (i = 0; i < num_scalers; i++) {
Robert Fekete3abc4e02015-10-27 16:58:32 +01003163 struct intel_scaler *sc =
3164 &pipe_config->scaler_state.scalers[i];
3165
3166 seq_printf(m, ", scalers[%d]: use=%s, mode=%x",
3167 i, yesno(sc->in_use), sc->mode);
3168 }
3169 seq_puts(m, "\n");
3170 } else {
3171 seq_puts(m, "\tNo scalers available on this platform\n");
3172 }
3173}
3174
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003175static int i915_display_info(struct seq_file *m, void *unused)
3176{
David Weinehall36cdd012016-08-22 13:59:31 +03003177 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3178 struct drm_device *dev = &dev_priv->drm;
Chris Wilson065f2ec2014-03-12 09:13:13 +00003179 struct intel_crtc *crtc;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003180 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003181 struct drm_connector_list_iter conn_iter;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003182
Paulo Zanonib0e5ddf2014-04-01 14:55:10 -03003183 intel_runtime_pm_get(dev_priv);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003184 seq_printf(m, "CRTC info\n");
3185 seq_printf(m, "---------\n");
Damien Lespiaud3fcc802014-05-13 23:32:22 +01003186 for_each_intel_crtc(dev, crtc) {
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003187 struct intel_crtc_state *pipe_config;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003188
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003189 drm_modeset_lock(&crtc->base.mutex, NULL);
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003190 pipe_config = to_intel_crtc_state(crtc->base.state);
3191
Robert Fekete3abc4e02015-10-27 16:58:32 +01003192 seq_printf(m, "CRTC %d: pipe: %c, active=%s, (size=%dx%d), dither=%s, bpp=%d\n",
Chris Wilson065f2ec2014-03-12 09:13:13 +00003193 crtc->base.base.id, pipe_name(crtc->pipe),
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003194 yesno(pipe_config->base.active),
Robert Fekete3abc4e02015-10-27 16:58:32 +01003195 pipe_config->pipe_src_w, pipe_config->pipe_src_h,
3196 yesno(pipe_config->dither), pipe_config->pipe_bpp);
3197
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003198 if (pipe_config->base.active) {
Ville Syrjäläcd5dcbf2017-03-27 21:55:35 +03003199 struct intel_plane *cursor =
3200 to_intel_plane(crtc->base.cursor);
3201
Chris Wilson065f2ec2014-03-12 09:13:13 +00003202 intel_crtc_info(m, crtc);
3203
Ville Syrjäläcd5dcbf2017-03-27 21:55:35 +03003204 seq_printf(m, "\tcursor visible? %s, position (%d, %d), size %dx%d, addr 0x%08x\n",
3205 yesno(cursor->base.state->visible),
3206 cursor->base.state->crtc_x,
3207 cursor->base.state->crtc_y,
3208 cursor->base.state->crtc_w,
3209 cursor->base.state->crtc_h,
3210 cursor->cursor.base);
Robert Fekete3abc4e02015-10-27 16:58:32 +01003211 intel_scaler_info(m, crtc);
3212 intel_plane_info(m, crtc);
Paulo Zanonia23dc652014-04-01 14:55:11 -03003213 }
Daniel Vettercace8412014-05-22 17:56:31 +02003214
3215 seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n",
3216 yesno(!crtc->cpu_fifo_underrun_disabled),
3217 yesno(!crtc->pch_fifo_underrun_disabled));
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003218 drm_modeset_unlock(&crtc->base.mutex);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003219 }
3220
3221 seq_printf(m, "\n");
3222 seq_printf(m, "Connector info\n");
3223 seq_printf(m, "--------------\n");
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003224 mutex_lock(&dev->mode_config.mutex);
3225 drm_connector_list_iter_begin(dev, &conn_iter);
3226 drm_for_each_connector_iter(connector, &conn_iter)
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003227 intel_connector_info(m, connector);
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003228 drm_connector_list_iter_end(&conn_iter);
3229 mutex_unlock(&dev->mode_config.mutex);
3230
Paulo Zanonib0e5ddf2014-04-01 14:55:10 -03003231 intel_runtime_pm_put(dev_priv);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003232
3233 return 0;
3234}
3235
Chris Wilson1b365952016-10-04 21:11:31 +01003236static int i915_engine_info(struct seq_file *m, void *unused)
3237{
3238 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3239 struct intel_engine_cs *engine;
Akash Goel3b3f1652016-10-13 22:44:48 +05303240 enum intel_engine_id id;
Chris Wilsonf636edb2017-10-09 12:02:57 +01003241 struct drm_printer p;
Chris Wilson1b365952016-10-04 21:11:31 +01003242
Chris Wilson9c870d02016-10-24 13:42:15 +01003243 intel_runtime_pm_get(dev_priv);
3244
Chris Wilsonf73b5672017-03-02 15:03:56 +00003245 seq_printf(m, "GT awake? %s\n",
3246 yesno(dev_priv->gt.awake));
3247 seq_printf(m, "Global active requests: %d\n",
3248 dev_priv->gt.active_requests);
3249
Chris Wilsonf636edb2017-10-09 12:02:57 +01003250 p = drm_seq_file_printer(m);
3251 for_each_engine(engine, dev_priv, id)
3252 intel_engine_dump(engine, &p);
Chris Wilson1b365952016-10-04 21:11:31 +01003253
Chris Wilson9c870d02016-10-24 13:42:15 +01003254 intel_runtime_pm_put(dev_priv);
3255
Chris Wilson1b365952016-10-04 21:11:31 +01003256 return 0;
3257}
3258
Chris Wilsonc5418a82017-10-13 21:26:19 +01003259static int i915_shrinker_info(struct seq_file *m, void *unused)
3260{
3261 struct drm_i915_private *i915 = node_to_i915(m->private);
3262
3263 seq_printf(m, "seeks = %d\n", i915->mm.shrinker.seeks);
3264 seq_printf(m, "batch = %lu\n", i915->mm.shrinker.batch);
3265
3266 return 0;
3267}
3268
Ben Widawskye04934c2014-06-30 09:53:42 -07003269static int i915_semaphore_status(struct seq_file *m, void *unused)
3270{
David Weinehall36cdd012016-08-22 13:59:31 +03003271 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3272 struct drm_device *dev = &dev_priv->drm;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003273 struct intel_engine_cs *engine;
David Weinehall36cdd012016-08-22 13:59:31 +03003274 int num_rings = INTEL_INFO(dev_priv)->num_rings;
Dave Gordonc3232b12016-03-23 18:19:53 +00003275 enum intel_engine_id id;
3276 int j, ret;
Ben Widawskye04934c2014-06-30 09:53:42 -07003277
Michal Wajdeczko4f044a82017-09-19 19:38:44 +00003278 if (!i915_modparams.semaphores) {
Ben Widawskye04934c2014-06-30 09:53:42 -07003279 seq_puts(m, "Semaphores are disabled\n");
3280 return 0;
3281 }
3282
3283 ret = mutex_lock_interruptible(&dev->struct_mutex);
3284 if (ret)
3285 return ret;
Paulo Zanoni03872062014-07-09 14:31:57 -03003286 intel_runtime_pm_get(dev_priv);
Ben Widawskye04934c2014-06-30 09:53:42 -07003287
David Weinehall36cdd012016-08-22 13:59:31 +03003288 if (IS_BROADWELL(dev_priv)) {
Ben Widawskye04934c2014-06-30 09:53:42 -07003289 struct page *page;
3290 uint64_t *seqno;
3291
Chris Wilson51d545d2016-08-15 10:49:02 +01003292 page = i915_gem_object_get_page(dev_priv->semaphore->obj, 0);
Ben Widawskye04934c2014-06-30 09:53:42 -07003293
3294 seqno = (uint64_t *)kmap_atomic(page);
Akash Goel3b3f1652016-10-13 22:44:48 +05303295 for_each_engine(engine, dev_priv, id) {
Ben Widawskye04934c2014-06-30 09:53:42 -07003296 uint64_t offset;
3297
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003298 seq_printf(m, "%s\n", engine->name);
Ben Widawskye04934c2014-06-30 09:53:42 -07003299
3300 seq_puts(m, " Last signal:");
3301 for (j = 0; j < num_rings; j++) {
Dave Gordonc3232b12016-03-23 18:19:53 +00003302 offset = id * I915_NUM_ENGINES + j;
Ben Widawskye04934c2014-06-30 09:53:42 -07003303 seq_printf(m, "0x%08llx (0x%02llx) ",
3304 seqno[offset], offset * 8);
3305 }
3306 seq_putc(m, '\n');
3307
3308 seq_puts(m, " Last wait: ");
3309 for (j = 0; j < num_rings; j++) {
Dave Gordonc3232b12016-03-23 18:19:53 +00003310 offset = id + (j * I915_NUM_ENGINES);
Ben Widawskye04934c2014-06-30 09:53:42 -07003311 seq_printf(m, "0x%08llx (0x%02llx) ",
3312 seqno[offset], offset * 8);
3313 }
3314 seq_putc(m, '\n');
3315
3316 }
3317 kunmap_atomic(seqno);
3318 } else {
3319 seq_puts(m, " Last signal:");
Akash Goel3b3f1652016-10-13 22:44:48 +05303320 for_each_engine(engine, dev_priv, id)
Ben Widawskye04934c2014-06-30 09:53:42 -07003321 for (j = 0; j < num_rings; j++)
3322 seq_printf(m, "0x%08x\n",
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003323 I915_READ(engine->semaphore.mbox.signal[j]));
Ben Widawskye04934c2014-06-30 09:53:42 -07003324 seq_putc(m, '\n');
3325 }
3326
Paulo Zanoni03872062014-07-09 14:31:57 -03003327 intel_runtime_pm_put(dev_priv);
Ben Widawskye04934c2014-06-30 09:53:42 -07003328 mutex_unlock(&dev->struct_mutex);
3329 return 0;
3330}
3331
Daniel Vetter728e29d2014-06-25 22:01:53 +03003332static int i915_shared_dplls_info(struct seq_file *m, void *unused)
3333{
David Weinehall36cdd012016-08-22 13:59:31 +03003334 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3335 struct drm_device *dev = &dev_priv->drm;
Daniel Vetter728e29d2014-06-25 22:01:53 +03003336 int i;
3337
3338 drm_modeset_lock_all(dev);
3339 for (i = 0; i < dev_priv->num_shared_dpll; i++) {
3340 struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i];
3341
3342 seq_printf(m, "DPLL%i: %s, id: %i\n", i, pll->name, pll->id);
Maarten Lankhorst2dd66ebd2016-03-14 09:27:52 +01003343 seq_printf(m, " crtc_mask: 0x%08x, active: 0x%x, on: %s\n",
Ander Conselvan de Oliveira2c42e532016-12-29 17:22:09 +02003344 pll->state.crtc_mask, pll->active_mask, yesno(pll->on));
Daniel Vetter728e29d2014-06-25 22:01:53 +03003345 seq_printf(m, " tracked hardware state:\n");
Ander Conselvan de Oliveira2c42e532016-12-29 17:22:09 +02003346 seq_printf(m, " dpll: 0x%08x\n", pll->state.hw_state.dpll);
Ander Conselvan de Oliveira3e369b72014-10-29 11:32:32 +02003347 seq_printf(m, " dpll_md: 0x%08x\n",
Ander Conselvan de Oliveira2c42e532016-12-29 17:22:09 +02003348 pll->state.hw_state.dpll_md);
3349 seq_printf(m, " fp0: 0x%08x\n", pll->state.hw_state.fp0);
3350 seq_printf(m, " fp1: 0x%08x\n", pll->state.hw_state.fp1);
3351 seq_printf(m, " wrpll: 0x%08x\n", pll->state.hw_state.wrpll);
Daniel Vetter728e29d2014-06-25 22:01:53 +03003352 }
3353 drm_modeset_unlock_all(dev);
3354
3355 return 0;
3356}
3357
Damien Lespiau1ed1ef92014-08-30 16:50:59 +01003358static int i915_wa_registers(struct seq_file *m, void *unused)
Arun Siluvery888b5992014-08-26 14:44:51 +01003359{
3360 int i;
3361 int ret;
Tvrtko Ursuline2f80392016-03-16 11:00:36 +00003362 struct intel_engine_cs *engine;
David Weinehall36cdd012016-08-22 13:59:31 +03003363 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3364 struct drm_device *dev = &dev_priv->drm;
Arun Siluvery33136b02016-01-21 21:43:47 +00003365 struct i915_workarounds *workarounds = &dev_priv->workarounds;
Dave Gordonc3232b12016-03-23 18:19:53 +00003366 enum intel_engine_id id;
Arun Siluvery888b5992014-08-26 14:44:51 +01003367
Arun Siluvery888b5992014-08-26 14:44:51 +01003368 ret = mutex_lock_interruptible(&dev->struct_mutex);
3369 if (ret)
3370 return ret;
3371
3372 intel_runtime_pm_get(dev_priv);
3373
Arun Siluvery33136b02016-01-21 21:43:47 +00003374 seq_printf(m, "Workarounds applied: %d\n", workarounds->count);
Akash Goel3b3f1652016-10-13 22:44:48 +05303375 for_each_engine(engine, dev_priv, id)
Arun Siluvery33136b02016-01-21 21:43:47 +00003376 seq_printf(m, "HW whitelist count for %s: %d\n",
Dave Gordonc3232b12016-03-23 18:19:53 +00003377 engine->name, workarounds->hw_whitelist_count[id]);
Arun Siluvery33136b02016-01-21 21:43:47 +00003378 for (i = 0; i < workarounds->count; ++i) {
Ville Syrjäläf0f59a02015-11-18 15:33:26 +02003379 i915_reg_t addr;
3380 u32 mask, value, read;
Mika Kuoppala2fa60f62014-10-07 17:21:27 +03003381 bool ok;
Arun Siluvery888b5992014-08-26 14:44:51 +01003382
Arun Siluvery33136b02016-01-21 21:43:47 +00003383 addr = workarounds->reg[i].addr;
3384 mask = workarounds->reg[i].mask;
3385 value = workarounds->reg[i].value;
Mika Kuoppala2fa60f62014-10-07 17:21:27 +03003386 read = I915_READ(addr);
3387 ok = (value & mask) == (read & mask);
3388 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 +02003389 i915_mmio_reg_offset(addr), value, mask, read, ok ? "OK" : "FAIL");
Arun Siluvery888b5992014-08-26 14:44:51 +01003390 }
3391
3392 intel_runtime_pm_put(dev_priv);
3393 mutex_unlock(&dev->struct_mutex);
3394
3395 return 0;
3396}
3397
Kumar, Maheshd2d4f392017-08-17 19:15:29 +05303398static int i915_ipc_status_show(struct seq_file *m, void *data)
3399{
3400 struct drm_i915_private *dev_priv = m->private;
3401
3402 seq_printf(m, "Isochronous Priority Control: %s\n",
3403 yesno(dev_priv->ipc_enabled));
3404 return 0;
3405}
3406
3407static int i915_ipc_status_open(struct inode *inode, struct file *file)
3408{
3409 struct drm_i915_private *dev_priv = inode->i_private;
3410
3411 if (!HAS_IPC(dev_priv))
3412 return -ENODEV;
3413
3414 return single_open(file, i915_ipc_status_show, dev_priv);
3415}
3416
3417static ssize_t i915_ipc_status_write(struct file *file, const char __user *ubuf,
3418 size_t len, loff_t *offp)
3419{
3420 struct seq_file *m = file->private_data;
3421 struct drm_i915_private *dev_priv = m->private;
3422 int ret;
3423 bool enable;
3424
3425 ret = kstrtobool_from_user(ubuf, len, &enable);
3426 if (ret < 0)
3427 return ret;
3428
3429 intel_runtime_pm_get(dev_priv);
3430 if (!dev_priv->ipc_enabled && enable)
3431 DRM_INFO("Enabling IPC: WM will be proper only after next commit\n");
3432 dev_priv->wm.distrust_bios_wm = true;
3433 dev_priv->ipc_enabled = enable;
3434 intel_enable_ipc(dev_priv);
3435 intel_runtime_pm_put(dev_priv);
3436
3437 return len;
3438}
3439
3440static const struct file_operations i915_ipc_status_fops = {
3441 .owner = THIS_MODULE,
3442 .open = i915_ipc_status_open,
3443 .read = seq_read,
3444 .llseek = seq_lseek,
3445 .release = single_release,
3446 .write = i915_ipc_status_write
3447};
3448
Damien Lespiauc5511e42014-11-04 17:06:51 +00003449static int i915_ddb_info(struct seq_file *m, void *unused)
3450{
David Weinehall36cdd012016-08-22 13:59:31 +03003451 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3452 struct drm_device *dev = &dev_priv->drm;
Damien Lespiauc5511e42014-11-04 17:06:51 +00003453 struct skl_ddb_allocation *ddb;
3454 struct skl_ddb_entry *entry;
3455 enum pipe pipe;
3456 int plane;
3457
David Weinehall36cdd012016-08-22 13:59:31 +03003458 if (INTEL_GEN(dev_priv) < 9)
Damien Lespiau2fcffe12014-12-03 17:33:24 +00003459 return 0;
3460
Damien Lespiauc5511e42014-11-04 17:06:51 +00003461 drm_modeset_lock_all(dev);
3462
3463 ddb = &dev_priv->wm.skl_hw.ddb;
3464
3465 seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size");
3466
3467 for_each_pipe(dev_priv, pipe) {
3468 seq_printf(m, "Pipe %c\n", pipe_name(pipe));
3469
Matt Roper8b364b42016-10-26 15:51:28 -07003470 for_each_universal_plane(dev_priv, pipe, plane) {
Damien Lespiauc5511e42014-11-04 17:06:51 +00003471 entry = &ddb->plane[pipe][plane];
3472 seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1,
3473 entry->start, entry->end,
3474 skl_ddb_entry_size(entry));
3475 }
3476
Matt Roper4969d332015-09-24 15:53:10 -07003477 entry = &ddb->plane[pipe][PLANE_CURSOR];
Damien Lespiauc5511e42014-11-04 17:06:51 +00003478 seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start,
3479 entry->end, skl_ddb_entry_size(entry));
3480 }
3481
3482 drm_modeset_unlock_all(dev);
3483
3484 return 0;
3485}
3486
Vandana Kannana54746e2015-03-03 20:53:10 +05303487static void drrs_status_per_crtc(struct seq_file *m,
David Weinehall36cdd012016-08-22 13:59:31 +03003488 struct drm_device *dev,
3489 struct intel_crtc *intel_crtc)
Vandana Kannana54746e2015-03-03 20:53:10 +05303490{
Chris Wilsonfac5e232016-07-04 11:34:36 +01003491 struct drm_i915_private *dev_priv = to_i915(dev);
Vandana Kannana54746e2015-03-03 20:53:10 +05303492 struct i915_drrs *drrs = &dev_priv->drrs;
3493 int vrefresh = 0;
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003494 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003495 struct drm_connector_list_iter conn_iter;
Vandana Kannana54746e2015-03-03 20:53:10 +05303496
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003497 drm_connector_list_iter_begin(dev, &conn_iter);
3498 drm_for_each_connector_iter(connector, &conn_iter) {
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003499 if (connector->state->crtc != &intel_crtc->base)
3500 continue;
3501
3502 seq_printf(m, "%s:\n", connector->name);
Vandana Kannana54746e2015-03-03 20:53:10 +05303503 }
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003504 drm_connector_list_iter_end(&conn_iter);
Vandana Kannana54746e2015-03-03 20:53:10 +05303505
3506 if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT)
3507 seq_puts(m, "\tVBT: DRRS_type: Static");
3508 else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT)
3509 seq_puts(m, "\tVBT: DRRS_type: Seamless");
3510 else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED)
3511 seq_puts(m, "\tVBT: DRRS_type: None");
3512 else
3513 seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value");
3514
3515 seq_puts(m, "\n\n");
3516
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003517 if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) {
Vandana Kannana54746e2015-03-03 20:53:10 +05303518 struct intel_panel *panel;
3519
3520 mutex_lock(&drrs->mutex);
3521 /* DRRS Supported */
3522 seq_puts(m, "\tDRRS Supported: Yes\n");
3523
3524 /* disable_drrs() will make drrs->dp NULL */
3525 if (!drrs->dp) {
3526 seq_puts(m, "Idleness DRRS: Disabled");
3527 mutex_unlock(&drrs->mutex);
3528 return;
3529 }
3530
3531 panel = &drrs->dp->attached_connector->panel;
3532 seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X",
3533 drrs->busy_frontbuffer_bits);
3534
3535 seq_puts(m, "\n\t\t");
3536 if (drrs->refresh_rate_type == DRRS_HIGH_RR) {
3537 seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n");
3538 vrefresh = panel->fixed_mode->vrefresh;
3539 } else if (drrs->refresh_rate_type == DRRS_LOW_RR) {
3540 seq_puts(m, "DRRS_State: DRRS_LOW_RR\n");
3541 vrefresh = panel->downclock_mode->vrefresh;
3542 } else {
3543 seq_printf(m, "DRRS_State: Unknown(%d)\n",
3544 drrs->refresh_rate_type);
3545 mutex_unlock(&drrs->mutex);
3546 return;
3547 }
3548 seq_printf(m, "\t\tVrefresh: %d", vrefresh);
3549
3550 seq_puts(m, "\n\t\t");
3551 mutex_unlock(&drrs->mutex);
3552 } else {
3553 /* DRRS not supported. Print the VBT parameter*/
3554 seq_puts(m, "\tDRRS Supported : No");
3555 }
3556 seq_puts(m, "\n");
3557}
3558
3559static int i915_drrs_status(struct seq_file *m, void *unused)
3560{
David Weinehall36cdd012016-08-22 13:59:31 +03003561 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3562 struct drm_device *dev = &dev_priv->drm;
Vandana Kannana54746e2015-03-03 20:53:10 +05303563 struct intel_crtc *intel_crtc;
3564 int active_crtc_cnt = 0;
3565
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003566 drm_modeset_lock_all(dev);
Vandana Kannana54746e2015-03-03 20:53:10 +05303567 for_each_intel_crtc(dev, intel_crtc) {
Maarten Lankhorstf77076c2015-06-01 12:50:08 +02003568 if (intel_crtc->base.state->active) {
Vandana Kannana54746e2015-03-03 20:53:10 +05303569 active_crtc_cnt++;
3570 seq_printf(m, "\nCRTC %d: ", active_crtc_cnt);
3571
3572 drrs_status_per_crtc(m, dev, intel_crtc);
3573 }
Vandana Kannana54746e2015-03-03 20:53:10 +05303574 }
Maarten Lankhorst26875fe2016-06-20 15:57:36 +02003575 drm_modeset_unlock_all(dev);
Vandana Kannana54746e2015-03-03 20:53:10 +05303576
3577 if (!active_crtc_cnt)
3578 seq_puts(m, "No active crtc found\n");
3579
3580 return 0;
3581}
3582
Dave Airlie11bed952014-05-12 15:22:27 +10003583static int i915_dp_mst_info(struct seq_file *m, void *unused)
3584{
David Weinehall36cdd012016-08-22 13:59:31 +03003585 struct drm_i915_private *dev_priv = node_to_i915(m->private);
3586 struct drm_device *dev = &dev_priv->drm;
Dave Airlie11bed952014-05-12 15:22:27 +10003587 struct intel_encoder *intel_encoder;
3588 struct intel_digital_port *intel_dig_port;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003589 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003590 struct drm_connector_list_iter conn_iter;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003591
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003592 drm_connector_list_iter_begin(dev, &conn_iter);
3593 drm_for_each_connector_iter(connector, &conn_iter) {
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003594 if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort)
Dave Airlie11bed952014-05-12 15:22:27 +10003595 continue;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003596
3597 intel_encoder = intel_attached_encoder(connector);
3598 if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST)
3599 continue;
3600
3601 intel_dig_port = enc_to_dig_port(&intel_encoder->base);
Dave Airlie11bed952014-05-12 15:22:27 +10003602 if (!intel_dig_port->dp.can_mst)
3603 continue;
Maarten Lankhorstb6dabe32016-06-20 15:57:37 +02003604
Jim Bride40ae80c2016-04-14 10:18:37 -07003605 seq_printf(m, "MST Source Port %c\n",
3606 port_name(intel_dig_port->port));
Dave Airlie11bed952014-05-12 15:22:27 +10003607 drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr);
3608 }
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003609 drm_connector_list_iter_end(&conn_iter);
3610
Dave Airlie11bed952014-05-12 15:22:27 +10003611 return 0;
3612}
3613
Todd Previteeb3394fa2015-04-18 00:04:19 -07003614static ssize_t i915_displayport_test_active_write(struct file *file,
David Weinehall36cdd012016-08-22 13:59:31 +03003615 const char __user *ubuf,
3616 size_t len, loff_t *offp)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003617{
3618 char *input_buffer;
3619 int status = 0;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003620 struct drm_device *dev;
3621 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003622 struct drm_connector_list_iter conn_iter;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003623 struct intel_dp *intel_dp;
3624 int val = 0;
3625
Sudip Mukherjee9aaffa32015-07-21 17:36:45 +05303626 dev = ((struct seq_file *)file->private_data)->private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003627
Todd Previteeb3394fa2015-04-18 00:04:19 -07003628 if (len == 0)
3629 return 0;
3630
Geliang Tang261aeba2017-05-06 23:40:17 +08003631 input_buffer = memdup_user_nul(ubuf, len);
3632 if (IS_ERR(input_buffer))
3633 return PTR_ERR(input_buffer);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003634
Todd Previteeb3394fa2015-04-18 00:04:19 -07003635 DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len);
3636
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 Lankhorsta874b6a2017-06-26 10:18:35 +02003639 struct intel_encoder *encoder;
3640
Todd Previteeb3394fa2015-04-18 00:04:19 -07003641 if (connector->connector_type !=
3642 DRM_MODE_CONNECTOR_DisplayPort)
3643 continue;
3644
Maarten Lankhorsta874b6a2017-06-26 10:18:35 +02003645 encoder = to_intel_encoder(connector->encoder);
3646 if (encoder && encoder->type == INTEL_OUTPUT_DP_MST)
3647 continue;
3648
3649 if (encoder && connector->status == connector_status_connected) {
3650 intel_dp = enc_to_intel_dp(&encoder->base);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003651 status = kstrtoint(input_buffer, 10, &val);
3652 if (status < 0)
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003653 break;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003654 DRM_DEBUG_DRIVER("Got %d for test active\n", val);
3655 /* To prevent erroneous activation of the compliance
3656 * testing code, only accept an actual value of 1 here
3657 */
3658 if (val == 1)
Manasi Navarec1617ab2016-12-09 16:22:50 -08003659 intel_dp->compliance.test_active = 1;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003660 else
Manasi Navarec1617ab2016-12-09 16:22:50 -08003661 intel_dp->compliance.test_active = 0;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003662 }
3663 }
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003664 drm_connector_list_iter_end(&conn_iter);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003665 kfree(input_buffer);
3666 if (status < 0)
3667 return status;
3668
3669 *offp += len;
3670 return len;
3671}
3672
3673static int i915_displayport_test_active_show(struct seq_file *m, void *data)
3674{
3675 struct drm_device *dev = m->private;
3676 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003677 struct drm_connector_list_iter conn_iter;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003678 struct intel_dp *intel_dp;
3679
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003680 drm_connector_list_iter_begin(dev, &conn_iter);
3681 drm_for_each_connector_iter(connector, &conn_iter) {
Maarten Lankhorsta874b6a2017-06-26 10:18:35 +02003682 struct intel_encoder *encoder;
3683
Todd Previteeb3394fa2015-04-18 00:04:19 -07003684 if (connector->connector_type !=
3685 DRM_MODE_CONNECTOR_DisplayPort)
3686 continue;
3687
Maarten Lankhorsta874b6a2017-06-26 10:18:35 +02003688 encoder = to_intel_encoder(connector->encoder);
3689 if (encoder && encoder->type == INTEL_OUTPUT_DP_MST)
3690 continue;
3691
3692 if (encoder && connector->status == connector_status_connected) {
3693 intel_dp = enc_to_intel_dp(&encoder->base);
Manasi Navarec1617ab2016-12-09 16:22:50 -08003694 if (intel_dp->compliance.test_active)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003695 seq_puts(m, "1");
3696 else
3697 seq_puts(m, "0");
3698 } else
3699 seq_puts(m, "0");
3700 }
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003701 drm_connector_list_iter_end(&conn_iter);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003702
3703 return 0;
3704}
3705
3706static int i915_displayport_test_active_open(struct inode *inode,
David Weinehall36cdd012016-08-22 13:59:31 +03003707 struct file *file)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003708{
David Weinehall36cdd012016-08-22 13:59:31 +03003709 struct drm_i915_private *dev_priv = inode->i_private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003710
David Weinehall36cdd012016-08-22 13:59:31 +03003711 return single_open(file, i915_displayport_test_active_show,
3712 &dev_priv->drm);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003713}
3714
3715static const struct file_operations i915_displayport_test_active_fops = {
3716 .owner = THIS_MODULE,
3717 .open = i915_displayport_test_active_open,
3718 .read = seq_read,
3719 .llseek = seq_lseek,
3720 .release = single_release,
3721 .write = i915_displayport_test_active_write
3722};
3723
3724static int i915_displayport_test_data_show(struct seq_file *m, void *data)
3725{
3726 struct drm_device *dev = m->private;
3727 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003728 struct drm_connector_list_iter conn_iter;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003729 struct intel_dp *intel_dp;
3730
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003731 drm_connector_list_iter_begin(dev, &conn_iter);
3732 drm_for_each_connector_iter(connector, &conn_iter) {
Maarten Lankhorsta874b6a2017-06-26 10:18:35 +02003733 struct intel_encoder *encoder;
3734
Todd Previteeb3394fa2015-04-18 00:04:19 -07003735 if (connector->connector_type !=
3736 DRM_MODE_CONNECTOR_DisplayPort)
3737 continue;
3738
Maarten Lankhorsta874b6a2017-06-26 10:18:35 +02003739 encoder = to_intel_encoder(connector->encoder);
3740 if (encoder && encoder->type == INTEL_OUTPUT_DP_MST)
3741 continue;
3742
3743 if (encoder && connector->status == connector_status_connected) {
3744 intel_dp = enc_to_intel_dp(&encoder->base);
Manasi Navareb48a5ba2017-01-20 19:09:28 -08003745 if (intel_dp->compliance.test_type ==
3746 DP_TEST_LINK_EDID_READ)
3747 seq_printf(m, "%lx",
3748 intel_dp->compliance.test_data.edid);
Manasi Navare611032b2017-01-24 08:21:49 -08003749 else if (intel_dp->compliance.test_type ==
3750 DP_TEST_LINK_VIDEO_PATTERN) {
3751 seq_printf(m, "hdisplay: %d\n",
3752 intel_dp->compliance.test_data.hdisplay);
3753 seq_printf(m, "vdisplay: %d\n",
3754 intel_dp->compliance.test_data.vdisplay);
3755 seq_printf(m, "bpc: %u\n",
3756 intel_dp->compliance.test_data.bpc);
3757 }
Todd Previteeb3394fa2015-04-18 00:04:19 -07003758 } else
3759 seq_puts(m, "0");
3760 }
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003761 drm_connector_list_iter_end(&conn_iter);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003762
3763 return 0;
3764}
3765static int i915_displayport_test_data_open(struct inode *inode,
David Weinehall36cdd012016-08-22 13:59:31 +03003766 struct file *file)
Todd Previteeb3394fa2015-04-18 00:04:19 -07003767{
David Weinehall36cdd012016-08-22 13:59:31 +03003768 struct drm_i915_private *dev_priv = inode->i_private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003769
David Weinehall36cdd012016-08-22 13:59:31 +03003770 return single_open(file, i915_displayport_test_data_show,
3771 &dev_priv->drm);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003772}
3773
3774static const struct file_operations i915_displayport_test_data_fops = {
3775 .owner = THIS_MODULE,
3776 .open = i915_displayport_test_data_open,
3777 .read = seq_read,
3778 .llseek = seq_lseek,
3779 .release = single_release
3780};
3781
3782static int i915_displayport_test_type_show(struct seq_file *m, void *data)
3783{
3784 struct drm_device *dev = m->private;
3785 struct drm_connector *connector;
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003786 struct drm_connector_list_iter conn_iter;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003787 struct intel_dp *intel_dp;
3788
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003789 drm_connector_list_iter_begin(dev, &conn_iter);
3790 drm_for_each_connector_iter(connector, &conn_iter) {
Maarten Lankhorsta874b6a2017-06-26 10:18:35 +02003791 struct intel_encoder *encoder;
3792
Todd Previteeb3394fa2015-04-18 00:04:19 -07003793 if (connector->connector_type !=
3794 DRM_MODE_CONNECTOR_DisplayPort)
3795 continue;
3796
Maarten Lankhorsta874b6a2017-06-26 10:18:35 +02003797 encoder = to_intel_encoder(connector->encoder);
3798 if (encoder && encoder->type == INTEL_OUTPUT_DP_MST)
3799 continue;
3800
3801 if (encoder && connector->status == connector_status_connected) {
3802 intel_dp = enc_to_intel_dp(&encoder->base);
Manasi Navarec1617ab2016-12-09 16:22:50 -08003803 seq_printf(m, "%02lx", intel_dp->compliance.test_type);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003804 } else
3805 seq_puts(m, "0");
3806 }
Daniel Vetter3f6a5e12017-03-01 10:52:21 +01003807 drm_connector_list_iter_end(&conn_iter);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003808
3809 return 0;
3810}
3811
3812static int i915_displayport_test_type_open(struct inode *inode,
3813 struct file *file)
3814{
David Weinehall36cdd012016-08-22 13:59:31 +03003815 struct drm_i915_private *dev_priv = inode->i_private;
Todd Previteeb3394fa2015-04-18 00:04:19 -07003816
David Weinehall36cdd012016-08-22 13:59:31 +03003817 return single_open(file, i915_displayport_test_type_show,
3818 &dev_priv->drm);
Todd Previteeb3394fa2015-04-18 00:04:19 -07003819}
3820
3821static const struct file_operations i915_displayport_test_type_fops = {
3822 .owner = THIS_MODULE,
3823 .open = i915_displayport_test_type_open,
3824 .read = seq_read,
3825 .llseek = seq_lseek,
3826 .release = single_release
3827};
3828
Damien Lespiau97e94b22014-11-04 17:06:50 +00003829static void wm_latency_show(struct seq_file *m, const uint16_t wm[8])
Ville Syrjälä369a1342014-01-22 14:36:08 +02003830{
David Weinehall36cdd012016-08-22 13:59:31 +03003831 struct drm_i915_private *dev_priv = m->private;
3832 struct drm_device *dev = &dev_priv->drm;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003833 int level;
Ville Syrjäläde38b952015-06-24 22:00:09 +03003834 int num_levels;
3835
David Weinehall36cdd012016-08-22 13:59:31 +03003836 if (IS_CHERRYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03003837 num_levels = 3;
David Weinehall36cdd012016-08-22 13:59:31 +03003838 else if (IS_VALLEYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03003839 num_levels = 1;
Ville Syrjälä04548cb2017-04-21 21:14:29 +03003840 else if (IS_G4X(dev_priv))
3841 num_levels = 3;
Ville Syrjäläde38b952015-06-24 22:00:09 +03003842 else
Tvrtko Ursulin5db94012016-10-13 11:03:10 +01003843 num_levels = ilk_wm_max_level(dev_priv) + 1;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003844
3845 drm_modeset_lock_all(dev);
3846
3847 for (level = 0; level < num_levels; level++) {
3848 unsigned int latency = wm[level];
3849
Damien Lespiau97e94b22014-11-04 17:06:50 +00003850 /*
3851 * - WM1+ latency values in 0.5us units
Ville Syrjäläde38b952015-06-24 22:00:09 +03003852 * - latencies are in us on gen9/vlv/chv
Damien Lespiau97e94b22014-11-04 17:06:50 +00003853 */
Ville Syrjälä04548cb2017-04-21 21:14:29 +03003854 if (INTEL_GEN(dev_priv) >= 9 ||
3855 IS_VALLEYVIEW(dev_priv) ||
3856 IS_CHERRYVIEW(dev_priv) ||
3857 IS_G4X(dev_priv))
Damien Lespiau97e94b22014-11-04 17:06:50 +00003858 latency *= 10;
3859 else if (level > 0)
Ville Syrjälä369a1342014-01-22 14:36:08 +02003860 latency *= 5;
3861
3862 seq_printf(m, "WM%d %u (%u.%u usec)\n",
Damien Lespiau97e94b22014-11-04 17:06:50 +00003863 level, wm[level], latency / 10, latency % 10);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003864 }
3865
3866 drm_modeset_unlock_all(dev);
3867}
3868
3869static int pri_wm_latency_show(struct seq_file *m, void *data)
3870{
David Weinehall36cdd012016-08-22 13:59:31 +03003871 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003872 const uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003873
David Weinehall36cdd012016-08-22 13:59:31 +03003874 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00003875 latencies = dev_priv->wm.skl_latency;
3876 else
David Weinehall36cdd012016-08-22 13:59:31 +03003877 latencies = dev_priv->wm.pri_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003878
3879 wm_latency_show(m, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003880
3881 return 0;
3882}
3883
3884static int spr_wm_latency_show(struct seq_file *m, void *data)
3885{
David Weinehall36cdd012016-08-22 13:59:31 +03003886 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003887 const uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003888
David Weinehall36cdd012016-08-22 13:59:31 +03003889 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00003890 latencies = dev_priv->wm.skl_latency;
3891 else
David Weinehall36cdd012016-08-22 13:59:31 +03003892 latencies = dev_priv->wm.spr_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003893
3894 wm_latency_show(m, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003895
3896 return 0;
3897}
3898
3899static int cur_wm_latency_show(struct seq_file *m, void *data)
3900{
David Weinehall36cdd012016-08-22 13:59:31 +03003901 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003902 const uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003903
David Weinehall36cdd012016-08-22 13:59:31 +03003904 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00003905 latencies = dev_priv->wm.skl_latency;
3906 else
David Weinehall36cdd012016-08-22 13:59:31 +03003907 latencies = dev_priv->wm.cur_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003908
3909 wm_latency_show(m, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003910
3911 return 0;
3912}
3913
3914static int pri_wm_latency_open(struct inode *inode, struct file *file)
3915{
David Weinehall36cdd012016-08-22 13:59:31 +03003916 struct drm_i915_private *dev_priv = inode->i_private;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003917
Ville Syrjälä04548cb2017-04-21 21:14:29 +03003918 if (INTEL_GEN(dev_priv) < 5 && !IS_G4X(dev_priv))
Ville Syrjälä369a1342014-01-22 14:36:08 +02003919 return -ENODEV;
3920
David Weinehall36cdd012016-08-22 13:59:31 +03003921 return single_open(file, pri_wm_latency_show, dev_priv);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003922}
3923
3924static int spr_wm_latency_open(struct inode *inode, struct file *file)
3925{
David Weinehall36cdd012016-08-22 13:59:31 +03003926 struct drm_i915_private *dev_priv = inode->i_private;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003927
David Weinehall36cdd012016-08-22 13:59:31 +03003928 if (HAS_GMCH_DISPLAY(dev_priv))
Ville Syrjälä369a1342014-01-22 14:36:08 +02003929 return -ENODEV;
3930
David Weinehall36cdd012016-08-22 13:59:31 +03003931 return single_open(file, spr_wm_latency_show, dev_priv);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003932}
3933
3934static int cur_wm_latency_open(struct inode *inode, struct file *file)
3935{
David Weinehall36cdd012016-08-22 13:59:31 +03003936 struct drm_i915_private *dev_priv = inode->i_private;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003937
David Weinehall36cdd012016-08-22 13:59:31 +03003938 if (HAS_GMCH_DISPLAY(dev_priv))
Ville Syrjälä369a1342014-01-22 14:36:08 +02003939 return -ENODEV;
3940
David Weinehall36cdd012016-08-22 13:59:31 +03003941 return single_open(file, cur_wm_latency_show, dev_priv);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003942}
3943
3944static ssize_t wm_latency_write(struct file *file, const char __user *ubuf,
Damien Lespiau97e94b22014-11-04 17:06:50 +00003945 size_t len, loff_t *offp, uint16_t wm[8])
Ville Syrjälä369a1342014-01-22 14:36:08 +02003946{
3947 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03003948 struct drm_i915_private *dev_priv = m->private;
3949 struct drm_device *dev = &dev_priv->drm;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003950 uint16_t new[8] = { 0 };
Ville Syrjäläde38b952015-06-24 22:00:09 +03003951 int num_levels;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003952 int level;
3953 int ret;
3954 char tmp[32];
3955
David Weinehall36cdd012016-08-22 13:59:31 +03003956 if (IS_CHERRYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03003957 num_levels = 3;
David Weinehall36cdd012016-08-22 13:59:31 +03003958 else if (IS_VALLEYVIEW(dev_priv))
Ville Syrjäläde38b952015-06-24 22:00:09 +03003959 num_levels = 1;
Ville Syrjälä04548cb2017-04-21 21:14:29 +03003960 else if (IS_G4X(dev_priv))
3961 num_levels = 3;
Ville Syrjäläde38b952015-06-24 22:00:09 +03003962 else
Tvrtko Ursulin5db94012016-10-13 11:03:10 +01003963 num_levels = ilk_wm_max_level(dev_priv) + 1;
Ville Syrjäläde38b952015-06-24 22:00:09 +03003964
Ville Syrjälä369a1342014-01-22 14:36:08 +02003965 if (len >= sizeof(tmp))
3966 return -EINVAL;
3967
3968 if (copy_from_user(tmp, ubuf, len))
3969 return -EFAULT;
3970
3971 tmp[len] = '\0';
3972
Damien Lespiau97e94b22014-11-04 17:06:50 +00003973 ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu",
3974 &new[0], &new[1], &new[2], &new[3],
3975 &new[4], &new[5], &new[6], &new[7]);
Ville Syrjälä369a1342014-01-22 14:36:08 +02003976 if (ret != num_levels)
3977 return -EINVAL;
3978
3979 drm_modeset_lock_all(dev);
3980
3981 for (level = 0; level < num_levels; level++)
3982 wm[level] = new[level];
3983
3984 drm_modeset_unlock_all(dev);
3985
3986 return len;
3987}
3988
3989
3990static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf,
3991 size_t len, loff_t *offp)
3992{
3993 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03003994 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00003995 uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003996
David Weinehall36cdd012016-08-22 13:59:31 +03003997 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00003998 latencies = dev_priv->wm.skl_latency;
3999 else
David Weinehall36cdd012016-08-22 13:59:31 +03004000 latencies = dev_priv->wm.pri_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004001
4002 return wm_latency_write(file, ubuf, len, offp, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004003}
4004
4005static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf,
4006 size_t len, loff_t *offp)
4007{
4008 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03004009 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004010 uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004011
David Weinehall36cdd012016-08-22 13:59:31 +03004012 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00004013 latencies = dev_priv->wm.skl_latency;
4014 else
David Weinehall36cdd012016-08-22 13:59:31 +03004015 latencies = dev_priv->wm.spr_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004016
4017 return wm_latency_write(file, ubuf, len, offp, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004018}
4019
4020static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf,
4021 size_t len, loff_t *offp)
4022{
4023 struct seq_file *m = file->private_data;
David Weinehall36cdd012016-08-22 13:59:31 +03004024 struct drm_i915_private *dev_priv = m->private;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004025 uint16_t *latencies;
Ville Syrjälä369a1342014-01-22 14:36:08 +02004026
David Weinehall36cdd012016-08-22 13:59:31 +03004027 if (INTEL_GEN(dev_priv) >= 9)
Damien Lespiau97e94b22014-11-04 17:06:50 +00004028 latencies = dev_priv->wm.skl_latency;
4029 else
David Weinehall36cdd012016-08-22 13:59:31 +03004030 latencies = dev_priv->wm.cur_latency;
Damien Lespiau97e94b22014-11-04 17:06:50 +00004031
4032 return wm_latency_write(file, ubuf, len, offp, latencies);
Ville Syrjälä369a1342014-01-22 14:36:08 +02004033}
4034
4035static const struct file_operations i915_pri_wm_latency_fops = {
4036 .owner = THIS_MODULE,
4037 .open = pri_wm_latency_open,
4038 .read = seq_read,
4039 .llseek = seq_lseek,
4040 .release = single_release,
4041 .write = pri_wm_latency_write
4042};
4043
4044static const struct file_operations i915_spr_wm_latency_fops = {
4045 .owner = THIS_MODULE,
4046 .open = spr_wm_latency_open,
4047 .read = seq_read,
4048 .llseek = seq_lseek,
4049 .release = single_release,
4050 .write = spr_wm_latency_write
4051};
4052
4053static const struct file_operations i915_cur_wm_latency_fops = {
4054 .owner = THIS_MODULE,
4055 .open = cur_wm_latency_open,
4056 .read = seq_read,
4057 .llseek = seq_lseek,
4058 .release = single_release,
4059 .write = cur_wm_latency_write
4060};
4061
Kees Cook647416f2013-03-10 14:10:06 -07004062static int
4063i915_wedged_get(void *data, u64 *val)
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004064{
David Weinehall36cdd012016-08-22 13:59:31 +03004065 struct drm_i915_private *dev_priv = data;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004066
Chris Wilsond98c52c2016-04-13 17:35:05 +01004067 *val = i915_terminally_wedged(&dev_priv->gpu_error);
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004068
Kees Cook647416f2013-03-10 14:10:06 -07004069 return 0;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004070}
4071
Kees Cook647416f2013-03-10 14:10:06 -07004072static int
4073i915_wedged_set(void *data, u64 val)
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004074{
Chris Wilson598b6b52017-03-25 13:47:35 +00004075 struct drm_i915_private *i915 = data;
4076 struct intel_engine_cs *engine;
4077 unsigned int tmp;
Imre Deakd46c0512014-04-14 20:24:27 +03004078
Mika Kuoppalab8d24a02015-01-28 17:03:14 +02004079 /*
4080 * There is no safeguard against this debugfs entry colliding
4081 * with the hangcheck calling same i915_handle_error() in
4082 * parallel, causing an explosion. For now we assume that the
4083 * test harness is responsible enough not to inject gpu hangs
4084 * while it is writing to 'i915_wedged'
4085 */
4086
Chris Wilson598b6b52017-03-25 13:47:35 +00004087 if (i915_reset_backoff(&i915->gpu_error))
Mika Kuoppalab8d24a02015-01-28 17:03:14 +02004088 return -EAGAIN;
4089
Chris Wilson598b6b52017-03-25 13:47:35 +00004090 for_each_engine_masked(engine, i915, val, tmp) {
4091 engine->hangcheck.seqno = intel_engine_get_seqno(engine);
4092 engine->hangcheck.stalled = true;
4093 }
Imre Deakd46c0512014-04-14 20:24:27 +03004094
Chris Wilson598b6b52017-03-25 13:47:35 +00004095 i915_handle_error(i915, val, "Manually setting wedged to %llu", val);
4096
4097 wait_on_bit(&i915->gpu_error.flags,
Chris Wilsond3df42b2017-03-16 17:13:05 +00004098 I915_RESET_HANDOFF,
4099 TASK_UNINTERRUPTIBLE);
4100
Kees Cook647416f2013-03-10 14:10:06 -07004101 return 0;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004102}
4103
Kees Cook647416f2013-03-10 14:10:06 -07004104DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops,
4105 i915_wedged_get, i915_wedged_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03004106 "%llu\n");
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004107
Kees Cook647416f2013-03-10 14:10:06 -07004108static int
Chris Wilson64486ae2017-03-07 15:59:08 +00004109fault_irq_set(struct drm_i915_private *i915,
4110 unsigned long *irq,
4111 unsigned long val)
4112{
4113 int err;
4114
4115 err = mutex_lock_interruptible(&i915->drm.struct_mutex);
4116 if (err)
4117 return err;
4118
4119 err = i915_gem_wait_for_idle(i915,
4120 I915_WAIT_LOCKED |
4121 I915_WAIT_INTERRUPTIBLE);
4122 if (err)
4123 goto err_unlock;
4124
Chris Wilson64486ae2017-03-07 15:59:08 +00004125 *irq = val;
4126 mutex_unlock(&i915->drm.struct_mutex);
4127
4128 /* Flush idle worker to disarm irq */
Chris Wilson7c262402017-10-06 11:40:38 +01004129 drain_delayed_work(&i915->gt.idle_work);
Chris Wilson64486ae2017-03-07 15:59:08 +00004130
4131 return 0;
4132
4133err_unlock:
4134 mutex_unlock(&i915->drm.struct_mutex);
4135 return err;
4136}
4137
4138static int
Chris Wilson094f9a52013-09-25 17:34:55 +01004139i915_ring_missed_irq_get(void *data, u64 *val)
4140{
David Weinehall36cdd012016-08-22 13:59:31 +03004141 struct drm_i915_private *dev_priv = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004142
4143 *val = dev_priv->gpu_error.missed_irq_rings;
4144 return 0;
4145}
4146
4147static int
4148i915_ring_missed_irq_set(void *data, u64 val)
4149{
Chris Wilson64486ae2017-03-07 15:59:08 +00004150 struct drm_i915_private *i915 = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004151
Chris Wilson64486ae2017-03-07 15:59:08 +00004152 return fault_irq_set(i915, &i915->gpu_error.missed_irq_rings, val);
Chris Wilson094f9a52013-09-25 17:34:55 +01004153}
4154
4155DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops,
4156 i915_ring_missed_irq_get, i915_ring_missed_irq_set,
4157 "0x%08llx\n");
4158
4159static int
4160i915_ring_test_irq_get(void *data, u64 *val)
4161{
David Weinehall36cdd012016-08-22 13:59:31 +03004162 struct drm_i915_private *dev_priv = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004163
4164 *val = dev_priv->gpu_error.test_irq_rings;
4165
4166 return 0;
4167}
4168
4169static int
4170i915_ring_test_irq_set(void *data, u64 val)
4171{
Chris Wilson64486ae2017-03-07 15:59:08 +00004172 struct drm_i915_private *i915 = data;
Chris Wilson094f9a52013-09-25 17:34:55 +01004173
Chris Wilson64486ae2017-03-07 15:59:08 +00004174 val &= INTEL_INFO(i915)->ring_mask;
Chris Wilson094f9a52013-09-25 17:34:55 +01004175 DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val);
Chris Wilson094f9a52013-09-25 17:34:55 +01004176
Chris Wilson64486ae2017-03-07 15:59:08 +00004177 return fault_irq_set(i915, &i915->gpu_error.test_irq_rings, val);
Chris Wilson094f9a52013-09-25 17:34:55 +01004178}
4179
4180DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops,
4181 i915_ring_test_irq_get, i915_ring_test_irq_set,
4182 "0x%08llx\n");
4183
Chris Wilsonb4a0b322017-10-18 13:16:21 +01004184#define DROP_UNBOUND BIT(0)
4185#define DROP_BOUND BIT(1)
4186#define DROP_RETIRE BIT(2)
4187#define DROP_ACTIVE BIT(3)
4188#define DROP_FREED BIT(4)
4189#define DROP_SHRINK_ALL BIT(5)
4190#define DROP_IDLE BIT(6)
Chris Wilsonfbbd37b2016-10-28 13:58:42 +01004191#define DROP_ALL (DROP_UNBOUND | \
4192 DROP_BOUND | \
4193 DROP_RETIRE | \
4194 DROP_ACTIVE | \
Chris Wilson8eadc192017-03-08 14:46:22 +00004195 DROP_FREED | \
Chris Wilsonb4a0b322017-10-18 13:16:21 +01004196 DROP_SHRINK_ALL |\
4197 DROP_IDLE)
Kees Cook647416f2013-03-10 14:10:06 -07004198static int
4199i915_drop_caches_get(void *data, u64 *val)
Chris Wilsondd624af2013-01-15 12:39:35 +00004200{
Kees Cook647416f2013-03-10 14:10:06 -07004201 *val = DROP_ALL;
Chris Wilsondd624af2013-01-15 12:39:35 +00004202
Kees Cook647416f2013-03-10 14:10:06 -07004203 return 0;
Chris Wilsondd624af2013-01-15 12:39:35 +00004204}
4205
Kees Cook647416f2013-03-10 14:10:06 -07004206static int
4207i915_drop_caches_set(void *data, u64 val)
Chris Wilsondd624af2013-01-15 12:39:35 +00004208{
David Weinehall36cdd012016-08-22 13:59:31 +03004209 struct drm_i915_private *dev_priv = data;
4210 struct drm_device *dev = &dev_priv->drm;
Chris Wilson00c26cf2017-05-24 17:26:53 +01004211 int ret = 0;
Chris Wilsondd624af2013-01-15 12:39:35 +00004212
Chris Wilsonb4a0b322017-10-18 13:16:21 +01004213 DRM_DEBUG("Dropping caches: 0x%08llx [0x%08llx]\n",
4214 val, val & DROP_ALL);
Chris Wilsondd624af2013-01-15 12:39:35 +00004215
4216 /* No need to check and wait for gpu resets, only libdrm auto-restarts
4217 * on ioctls on -EAGAIN. */
Chris Wilson00c26cf2017-05-24 17:26:53 +01004218 if (val & (DROP_ACTIVE | DROP_RETIRE)) {
4219 ret = mutex_lock_interruptible(&dev->struct_mutex);
Chris Wilsondd624af2013-01-15 12:39:35 +00004220 if (ret)
Chris Wilson00c26cf2017-05-24 17:26:53 +01004221 return ret;
Chris Wilsondd624af2013-01-15 12:39:35 +00004222
Chris Wilson00c26cf2017-05-24 17:26:53 +01004223 if (val & DROP_ACTIVE)
4224 ret = i915_gem_wait_for_idle(dev_priv,
4225 I915_WAIT_INTERRUPTIBLE |
4226 I915_WAIT_LOCKED);
4227
4228 if (val & DROP_RETIRE)
4229 i915_gem_retire_requests(dev_priv);
4230
4231 mutex_unlock(&dev->struct_mutex);
4232 }
Chris Wilsondd624af2013-01-15 12:39:35 +00004233
Peter Zijlstrad92a8cf2017-03-03 10:13:38 +01004234 fs_reclaim_acquire(GFP_KERNEL);
Chris Wilson21ab4e72014-09-09 11:16:08 +01004235 if (val & DROP_BOUND)
Chris Wilson912d5722017-09-06 16:19:30 -07004236 i915_gem_shrink(dev_priv, LONG_MAX, NULL, I915_SHRINK_BOUND);
Chris Wilson4ad72b72014-09-03 19:23:37 +01004237
Chris Wilson21ab4e72014-09-09 11:16:08 +01004238 if (val & DROP_UNBOUND)
Chris Wilson912d5722017-09-06 16:19:30 -07004239 i915_gem_shrink(dev_priv, LONG_MAX, NULL, I915_SHRINK_UNBOUND);
Chris Wilsondd624af2013-01-15 12:39:35 +00004240
Chris Wilson8eadc192017-03-08 14:46:22 +00004241 if (val & DROP_SHRINK_ALL)
4242 i915_gem_shrink_all(dev_priv);
Peter Zijlstrad92a8cf2017-03-03 10:13:38 +01004243 fs_reclaim_release(GFP_KERNEL);
Chris Wilson8eadc192017-03-08 14:46:22 +00004244
Chris Wilsonb4a0b322017-10-18 13:16:21 +01004245 if (val & DROP_IDLE)
4246 drain_delayed_work(&dev_priv->gt.idle_work);
4247
Chris Wilsonfbbd37b2016-10-28 13:58:42 +01004248 if (val & DROP_FREED) {
4249 synchronize_rcu();
Chris Wilsonbdeb9782016-12-23 14:57:56 +00004250 i915_gem_drain_freed_objects(dev_priv);
Chris Wilsonfbbd37b2016-10-28 13:58:42 +01004251 }
4252
Kees Cook647416f2013-03-10 14:10:06 -07004253 return ret;
Chris Wilsondd624af2013-01-15 12:39:35 +00004254}
4255
Kees Cook647416f2013-03-10 14:10:06 -07004256DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops,
4257 i915_drop_caches_get, i915_drop_caches_set,
4258 "0x%08llx\n");
Chris Wilsondd624af2013-01-15 12:39:35 +00004259
Kees Cook647416f2013-03-10 14:10:06 -07004260static int
4261i915_max_freq_get(void *data, u64 *val)
Jesse Barnes358733e2011-07-27 11:53:01 -07004262{
David Weinehall36cdd012016-08-22 13:59:31 +03004263 struct drm_i915_private *dev_priv = data;
Daniel Vetter004777c2012-08-09 15:07:01 +02004264
David Weinehall36cdd012016-08-22 13:59:31 +03004265 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004266 return -ENODEV;
4267
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01004268 *val = intel_gpu_freq(dev_priv, dev_priv->gt_pm.rps.max_freq_softlimit);
Kees Cook647416f2013-03-10 14:10:06 -07004269 return 0;
Jesse Barnes358733e2011-07-27 11:53:01 -07004270}
4271
Kees Cook647416f2013-03-10 14:10:06 -07004272static int
4273i915_max_freq_set(void *data, u64 val)
Jesse Barnes358733e2011-07-27 11:53:01 -07004274{
David Weinehall36cdd012016-08-22 13:59:31 +03004275 struct drm_i915_private *dev_priv = data;
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01004276 struct intel_rps *rps = &dev_priv->gt_pm.rps;
Akash Goelbc4d91f2015-02-26 16:09:47 +05304277 u32 hw_max, hw_min;
Kees Cook647416f2013-03-10 14:10:06 -07004278 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02004279
David Weinehall36cdd012016-08-22 13:59:31 +03004280 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004281 return -ENODEV;
Jesse Barnes358733e2011-07-27 11:53:01 -07004282
Kees Cook647416f2013-03-10 14:10:06 -07004283 DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val);
Jesse Barnes358733e2011-07-27 11:53:01 -07004284
Sagar Arun Kamble9f817502017-10-10 22:30:05 +01004285 ret = mutex_lock_interruptible(&dev_priv->pcu_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02004286 if (ret)
4287 return ret;
4288
Jesse Barnes358733e2011-07-27 11:53:01 -07004289 /*
4290 * Turbo will still be enabled, but won't go above the set value.
4291 */
Akash Goelbc4d91f2015-02-26 16:09:47 +05304292 val = intel_freq_opcode(dev_priv, val);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004293
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01004294 hw_max = rps->max_freq;
4295 hw_min = rps->min_freq;
Jesse Barnes0a073b82013-04-17 15:54:58 -07004296
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01004297 if (val < hw_min || val > hw_max || val < rps->min_freq_softlimit) {
Sagar Arun Kamble9f817502017-10-10 22:30:05 +01004298 mutex_unlock(&dev_priv->pcu_lock);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004299 return -EINVAL;
4300 }
4301
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01004302 rps->max_freq_softlimit = val;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004303
Chris Wilson9fcee2f2017-01-26 10:19:19 +00004304 if (intel_set_rps(dev_priv, val))
4305 DRM_DEBUG_DRIVER("failed to update RPS to new softlimit\n");
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004306
Sagar Arun Kamble9f817502017-10-10 22:30:05 +01004307 mutex_unlock(&dev_priv->pcu_lock);
Jesse Barnes358733e2011-07-27 11:53:01 -07004308
Kees Cook647416f2013-03-10 14:10:06 -07004309 return 0;
Jesse Barnes358733e2011-07-27 11:53:01 -07004310}
4311
Kees Cook647416f2013-03-10 14:10:06 -07004312DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops,
4313 i915_max_freq_get, i915_max_freq_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03004314 "%llu\n");
Jesse Barnes358733e2011-07-27 11:53:01 -07004315
Kees Cook647416f2013-03-10 14:10:06 -07004316static int
4317i915_min_freq_get(void *data, u64 *val)
Jesse Barnes1523c312012-05-25 12:34:54 -07004318{
David Weinehall36cdd012016-08-22 13:59:31 +03004319 struct drm_i915_private *dev_priv = data;
Daniel Vetter004777c2012-08-09 15:07:01 +02004320
Chris Wilson62e1baa2016-07-13 09:10:36 +01004321 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004322 return -ENODEV;
4323
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01004324 *val = intel_gpu_freq(dev_priv, dev_priv->gt_pm.rps.min_freq_softlimit);
Kees Cook647416f2013-03-10 14:10:06 -07004325 return 0;
Jesse Barnes1523c312012-05-25 12:34:54 -07004326}
4327
Kees Cook647416f2013-03-10 14:10:06 -07004328static int
4329i915_min_freq_set(void *data, u64 val)
Jesse Barnes1523c312012-05-25 12:34:54 -07004330{
David Weinehall36cdd012016-08-22 13:59:31 +03004331 struct drm_i915_private *dev_priv = data;
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01004332 struct intel_rps *rps = &dev_priv->gt_pm.rps;
Akash Goelbc4d91f2015-02-26 16:09:47 +05304333 u32 hw_max, hw_min;
Kees Cook647416f2013-03-10 14:10:06 -07004334 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02004335
Chris Wilson62e1baa2016-07-13 09:10:36 +01004336 if (INTEL_GEN(dev_priv) < 6)
Daniel Vetter004777c2012-08-09 15:07:01 +02004337 return -ENODEV;
Jesse Barnes1523c312012-05-25 12:34:54 -07004338
Kees Cook647416f2013-03-10 14:10:06 -07004339 DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val);
Jesse Barnes1523c312012-05-25 12:34:54 -07004340
Sagar Arun Kamble9f817502017-10-10 22:30:05 +01004341 ret = mutex_lock_interruptible(&dev_priv->pcu_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02004342 if (ret)
4343 return ret;
4344
Jesse Barnes1523c312012-05-25 12:34:54 -07004345 /*
4346 * Turbo will still be enabled, but won't go below the set value.
4347 */
Akash Goelbc4d91f2015-02-26 16:09:47 +05304348 val = intel_freq_opcode(dev_priv, val);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004349
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01004350 hw_max = rps->max_freq;
4351 hw_min = rps->min_freq;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004352
David Weinehall36cdd012016-08-22 13:59:31 +03004353 if (val < hw_min ||
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01004354 val > hw_max || val > rps->max_freq_softlimit) {
Sagar Arun Kamble9f817502017-10-10 22:30:05 +01004355 mutex_unlock(&dev_priv->pcu_lock);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004356 return -EINVAL;
4357 }
4358
Sagar Arun Kamble562d9ba2017-10-10 22:30:06 +01004359 rps->min_freq_softlimit = val;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004360
Chris Wilson9fcee2f2017-01-26 10:19:19 +00004361 if (intel_set_rps(dev_priv, val))
4362 DRM_DEBUG_DRIVER("failed to update RPS to new softlimit\n");
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06004363
Sagar Arun Kamble9f817502017-10-10 22:30:05 +01004364 mutex_unlock(&dev_priv->pcu_lock);
Jesse Barnes1523c312012-05-25 12:34:54 -07004365
Kees Cook647416f2013-03-10 14:10:06 -07004366 return 0;
Jesse Barnes1523c312012-05-25 12:34:54 -07004367}
4368
Kees Cook647416f2013-03-10 14:10:06 -07004369DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops,
4370 i915_min_freq_get, i915_min_freq_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03004371 "%llu\n");
Jesse Barnes1523c312012-05-25 12:34:54 -07004372
Kees Cook647416f2013-03-10 14:10:06 -07004373static int
4374i915_cache_sharing_get(void *data, u64 *val)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004375{
David Weinehall36cdd012016-08-22 13:59:31 +03004376 struct drm_i915_private *dev_priv = data;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004377 u32 snpcr;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004378
David Weinehall36cdd012016-08-22 13:59:31 +03004379 if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv)))
Daniel Vetter004777c2012-08-09 15:07:01 +02004380 return -ENODEV;
4381
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004382 intel_runtime_pm_get(dev_priv);
Daniel Vetter22bcfc62012-08-09 15:07:02 +02004383
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004384 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004385
4386 intel_runtime_pm_put(dev_priv);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004387
Kees Cook647416f2013-03-10 14:10:06 -07004388 *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004389
Kees Cook647416f2013-03-10 14:10:06 -07004390 return 0;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004391}
4392
Kees Cook647416f2013-03-10 14:10:06 -07004393static int
4394i915_cache_sharing_set(void *data, u64 val)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004395{
David Weinehall36cdd012016-08-22 13:59:31 +03004396 struct drm_i915_private *dev_priv = data;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004397 u32 snpcr;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004398
David Weinehall36cdd012016-08-22 13:59:31 +03004399 if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv)))
Daniel Vetter004777c2012-08-09 15:07:01 +02004400 return -ENODEV;
4401
Kees Cook647416f2013-03-10 14:10:06 -07004402 if (val > 3)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004403 return -EINVAL;
4404
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004405 intel_runtime_pm_get(dev_priv);
Kees Cook647416f2013-03-10 14:10:06 -07004406 DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004407
4408 /* Update the cache sharing policy here as well */
4409 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
4410 snpcr &= ~GEN6_MBC_SNPCR_MASK;
4411 snpcr |= (val << GEN6_MBC_SNPCR_SHIFT);
4412 I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr);
4413
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02004414 intel_runtime_pm_put(dev_priv);
Kees Cook647416f2013-03-10 14:10:06 -07004415 return 0;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004416}
4417
Kees Cook647416f2013-03-10 14:10:06 -07004418DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops,
4419 i915_cache_sharing_get, i915_cache_sharing_set,
4420 "%llu\n");
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07004421
David Weinehall36cdd012016-08-22 13:59:31 +03004422static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv,
Imre Deak915490d2016-08-31 19:13:01 +03004423 struct sseu_dev_info *sseu)
Jeff McGee5d395252015-04-03 18:13:17 -07004424{
Ville Syrjälä0a0b4572015-08-21 20:45:27 +03004425 int ss_max = 2;
Jeff McGee5d395252015-04-03 18:13:17 -07004426 int ss;
4427 u32 sig1[ss_max], sig2[ss_max];
4428
4429 sig1[0] = I915_READ(CHV_POWER_SS0_SIG1);
4430 sig1[1] = I915_READ(CHV_POWER_SS1_SIG1);
4431 sig2[0] = I915_READ(CHV_POWER_SS0_SIG2);
4432 sig2[1] = I915_READ(CHV_POWER_SS1_SIG2);
4433
4434 for (ss = 0; ss < ss_max; ss++) {
4435 unsigned int eu_cnt;
4436
4437 if (sig1[ss] & CHV_SS_PG_ENABLE)
4438 /* skip disabled subslice */
4439 continue;
4440
Imre Deakf08a0c92016-08-31 19:13:04 +03004441 sseu->slice_mask = BIT(0);
Imre Deak57ec1712016-08-31 19:13:05 +03004442 sseu->subslice_mask |= BIT(ss);
Jeff McGee5d395252015-04-03 18:13:17 -07004443 eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) +
4444 ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) +
4445 ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) +
4446 ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2);
Imre Deak915490d2016-08-31 19:13:01 +03004447 sseu->eu_total += eu_cnt;
4448 sseu->eu_per_subslice = max_t(unsigned int,
4449 sseu->eu_per_subslice, eu_cnt);
Jeff McGee5d395252015-04-03 18:13:17 -07004450 }
Jeff McGee5d395252015-04-03 18:13:17 -07004451}
4452
Rodrigo Vivif8c3dcf2017-10-25 17:15:46 -07004453static void gen10_sseu_device_status(struct drm_i915_private *dev_priv,
4454 struct sseu_dev_info *sseu)
4455{
4456 const struct intel_device_info *info = INTEL_INFO(dev_priv);
4457 int s_max = 6, ss_max = 4;
4458 int s, ss;
4459 u32 s_reg[s_max], eu_reg[2 * s_max], eu_mask[2];
4460
4461 for (s = 0; s < s_max; s++) {
4462 /*
4463 * FIXME: Valid SS Mask respects the spec and read
4464 * only valid bits for those registers, excluding reserverd
4465 * although this seems wrong because it would leave many
4466 * subslices without ACK.
4467 */
4468 s_reg[s] = I915_READ(GEN10_SLICE_PGCTL_ACK(s)) &
4469 GEN10_PGCTL_VALID_SS_MASK(s);
4470 eu_reg[2 * s] = I915_READ(GEN10_SS01_EU_PGCTL_ACK(s));
4471 eu_reg[2 * s + 1] = I915_READ(GEN10_SS23_EU_PGCTL_ACK(s));
4472 }
4473
4474 eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK |
4475 GEN9_PGCTL_SSA_EU19_ACK |
4476 GEN9_PGCTL_SSA_EU210_ACK |
4477 GEN9_PGCTL_SSA_EU311_ACK;
4478 eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK |
4479 GEN9_PGCTL_SSB_EU19_ACK |
4480 GEN9_PGCTL_SSB_EU210_ACK |
4481 GEN9_PGCTL_SSB_EU311_ACK;
4482
4483 for (s = 0; s < s_max; s++) {
4484 if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0)
4485 /* skip disabled slice */
4486 continue;
4487
4488 sseu->slice_mask |= BIT(s);
4489 sseu->subslice_mask = info->sseu.subslice_mask;
4490
4491 for (ss = 0; ss < ss_max; ss++) {
4492 unsigned int eu_cnt;
4493
4494 if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss))))
4495 /* skip disabled subslice */
4496 continue;
4497
4498 eu_cnt = 2 * hweight32(eu_reg[2 * s + ss / 2] &
4499 eu_mask[ss % 2]);
4500 sseu->eu_total += eu_cnt;
4501 sseu->eu_per_subslice = max_t(unsigned int,
4502 sseu->eu_per_subslice,
4503 eu_cnt);
4504 }
4505 }
4506}
4507
David Weinehall36cdd012016-08-22 13:59:31 +03004508static void gen9_sseu_device_status(struct drm_i915_private *dev_priv,
Imre Deak915490d2016-08-31 19:13:01 +03004509 struct sseu_dev_info *sseu)
Jeff McGee5d395252015-04-03 18:13:17 -07004510{
Jeff McGee1c046bc2015-04-03 18:13:18 -07004511 int s_max = 3, ss_max = 4;
Jeff McGee5d395252015-04-03 18:13:17 -07004512 int s, ss;
4513 u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2];
4514
Jeff McGee1c046bc2015-04-03 18:13:18 -07004515 /* BXT has a single slice and at most 3 subslices. */
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02004516 if (IS_GEN9_LP(dev_priv)) {
Jeff McGee1c046bc2015-04-03 18:13:18 -07004517 s_max = 1;
4518 ss_max = 3;
4519 }
4520
4521 for (s = 0; s < s_max; s++) {
4522 s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s));
4523 eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s));
4524 eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s));
4525 }
4526
Jeff McGee5d395252015-04-03 18:13:17 -07004527 eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK |
4528 GEN9_PGCTL_SSA_EU19_ACK |
4529 GEN9_PGCTL_SSA_EU210_ACK |
4530 GEN9_PGCTL_SSA_EU311_ACK;
4531 eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK |
4532 GEN9_PGCTL_SSB_EU19_ACK |
4533 GEN9_PGCTL_SSB_EU210_ACK |
4534 GEN9_PGCTL_SSB_EU311_ACK;
4535
4536 for (s = 0; s < s_max; s++) {
4537 if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0)
4538 /* skip disabled slice */
4539 continue;
4540
Imre Deakf08a0c92016-08-31 19:13:04 +03004541 sseu->slice_mask |= BIT(s);
Jeff McGee1c046bc2015-04-03 18:13:18 -07004542
Rodrigo Vivif8c3dcf2017-10-25 17:15:46 -07004543 if (IS_GEN9_BC(dev_priv))
Imre Deak57ec1712016-08-31 19:13:05 +03004544 sseu->subslice_mask =
4545 INTEL_INFO(dev_priv)->sseu.subslice_mask;
Jeff McGee1c046bc2015-04-03 18:13:18 -07004546
Jeff McGee5d395252015-04-03 18:13:17 -07004547 for (ss = 0; ss < ss_max; ss++) {
4548 unsigned int eu_cnt;
4549
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +02004550 if (IS_GEN9_LP(dev_priv)) {
Imre Deak57ec1712016-08-31 19:13:05 +03004551 if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss))))
4552 /* skip disabled subslice */
4553 continue;
Jeff McGee1c046bc2015-04-03 18:13:18 -07004554
Imre Deak57ec1712016-08-31 19:13:05 +03004555 sseu->subslice_mask |= BIT(ss);
4556 }
Jeff McGee1c046bc2015-04-03 18:13:18 -07004557
Jeff McGee5d395252015-04-03 18:13:17 -07004558 eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] &
4559 eu_mask[ss%2]);
Imre Deak915490d2016-08-31 19:13:01 +03004560 sseu->eu_total += eu_cnt;
4561 sseu->eu_per_subslice = max_t(unsigned int,
4562 sseu->eu_per_subslice,
4563 eu_cnt);
Jeff McGee5d395252015-04-03 18:13:17 -07004564 }
4565 }
4566}
4567
David Weinehall36cdd012016-08-22 13:59:31 +03004568static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv,
Imre Deak915490d2016-08-31 19:13:01 +03004569 struct sseu_dev_info *sseu)
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004570{
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004571 u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO);
David Weinehall36cdd012016-08-22 13:59:31 +03004572 int s;
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004573
Imre Deakf08a0c92016-08-31 19:13:04 +03004574 sseu->slice_mask = slice_info & GEN8_LSLICESTAT_MASK;
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004575
Imre Deakf08a0c92016-08-31 19:13:04 +03004576 if (sseu->slice_mask) {
Imre Deak57ec1712016-08-31 19:13:05 +03004577 sseu->subslice_mask = INTEL_INFO(dev_priv)->sseu.subslice_mask;
Imre Deak43b67992016-08-31 19:13:02 +03004578 sseu->eu_per_subslice =
4579 INTEL_INFO(dev_priv)->sseu.eu_per_subslice;
Imre Deak57ec1712016-08-31 19:13:05 +03004580 sseu->eu_total = sseu->eu_per_subslice *
4581 sseu_subslice_total(sseu);
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004582
4583 /* subtract fused off EU(s) from enabled slice(s) */
Imre Deak795b38b2016-08-31 19:13:07 +03004584 for (s = 0; s < fls(sseu->slice_mask); s++) {
Imre Deak43b67992016-08-31 19:13:02 +03004585 u8 subslice_7eu =
4586 INTEL_INFO(dev_priv)->sseu.subslice_7eu[s];
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004587
Imre Deak915490d2016-08-31 19:13:01 +03004588 sseu->eu_total -= hweight8(subslice_7eu);
Łukasz Daniluk91bedd32015-09-25 11:54:58 +02004589 }
4590 }
4591}
4592
Imre Deak615d8902016-08-31 19:13:03 +03004593static void i915_print_sseu_info(struct seq_file *m, bool is_available_info,
4594 const struct sseu_dev_info *sseu)
4595{
4596 struct drm_i915_private *dev_priv = node_to_i915(m->private);
4597 const char *type = is_available_info ? "Available" : "Enabled";
4598
Imre Deakc67ba532016-08-31 19:13:06 +03004599 seq_printf(m, " %s Slice Mask: %04x\n", type,
4600 sseu->slice_mask);
Imre Deak615d8902016-08-31 19:13:03 +03004601 seq_printf(m, " %s Slice Total: %u\n", type,
Imre Deakf08a0c92016-08-31 19:13:04 +03004602 hweight8(sseu->slice_mask));
Imre Deak615d8902016-08-31 19:13:03 +03004603 seq_printf(m, " %s Subslice Total: %u\n", type,
Imre Deak57ec1712016-08-31 19:13:05 +03004604 sseu_subslice_total(sseu));
Imre Deakc67ba532016-08-31 19:13:06 +03004605 seq_printf(m, " %s Subslice Mask: %04x\n", type,
4606 sseu->subslice_mask);
Imre Deak615d8902016-08-31 19:13:03 +03004607 seq_printf(m, " %s Subslice Per Slice: %u\n", type,
Imre Deak57ec1712016-08-31 19:13:05 +03004608 hweight8(sseu->subslice_mask));
Imre Deak615d8902016-08-31 19:13:03 +03004609 seq_printf(m, " %s EU Total: %u\n", type,
4610 sseu->eu_total);
4611 seq_printf(m, " %s EU Per Subslice: %u\n", type,
4612 sseu->eu_per_subslice);
4613
4614 if (!is_available_info)
4615 return;
4616
4617 seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv)));
4618 if (HAS_POOLED_EU(dev_priv))
4619 seq_printf(m, " Min EU in pool: %u\n", sseu->min_eu_in_pool);
4620
4621 seq_printf(m, " Has Slice Power Gating: %s\n",
4622 yesno(sseu->has_slice_pg));
4623 seq_printf(m, " Has Subslice Power Gating: %s\n",
4624 yesno(sseu->has_subslice_pg));
4625 seq_printf(m, " Has EU Power Gating: %s\n",
4626 yesno(sseu->has_eu_pg));
4627}
4628
Jeff McGee38732182015-02-13 10:27:54 -06004629static int i915_sseu_status(struct seq_file *m, void *unused)
4630{
David Weinehall36cdd012016-08-22 13:59:31 +03004631 struct drm_i915_private *dev_priv = node_to_i915(m->private);
Imre Deak915490d2016-08-31 19:13:01 +03004632 struct sseu_dev_info sseu;
Jeff McGee38732182015-02-13 10:27:54 -06004633
David Weinehall36cdd012016-08-22 13:59:31 +03004634 if (INTEL_GEN(dev_priv) < 8)
Jeff McGee38732182015-02-13 10:27:54 -06004635 return -ENODEV;
4636
4637 seq_puts(m, "SSEU Device Info\n");
Imre Deak615d8902016-08-31 19:13:03 +03004638 i915_print_sseu_info(m, true, &INTEL_INFO(dev_priv)->sseu);
Jeff McGee38732182015-02-13 10:27:54 -06004639
Jeff McGee7f992ab2015-02-13 10:27:55 -06004640 seq_puts(m, "SSEU Device Status\n");
Imre Deak915490d2016-08-31 19:13:01 +03004641 memset(&sseu, 0, sizeof(sseu));
David Weinehall238010e2016-08-01 17:33:27 +03004642
4643 intel_runtime_pm_get(dev_priv);
4644
David Weinehall36cdd012016-08-22 13:59:31 +03004645 if (IS_CHERRYVIEW(dev_priv)) {
Imre Deak915490d2016-08-31 19:13:01 +03004646 cherryview_sseu_device_status(dev_priv, &sseu);
David Weinehall36cdd012016-08-22 13:59:31 +03004647 } else if (IS_BROADWELL(dev_priv)) {
Imre Deak915490d2016-08-31 19:13:01 +03004648 broadwell_sseu_device_status(dev_priv, &sseu);
Rodrigo Vivif8c3dcf2017-10-25 17:15:46 -07004649 } else if (IS_GEN9(dev_priv)) {
Imre Deak915490d2016-08-31 19:13:01 +03004650 gen9_sseu_device_status(dev_priv, &sseu);
Rodrigo Vivif8c3dcf2017-10-25 17:15:46 -07004651 } else if (INTEL_GEN(dev_priv) >= 10) {
4652 gen10_sseu_device_status(dev_priv, &sseu);
Jeff McGee7f992ab2015-02-13 10:27:55 -06004653 }
David Weinehall238010e2016-08-01 17:33:27 +03004654
4655 intel_runtime_pm_put(dev_priv);
4656
Imre Deak615d8902016-08-31 19:13:03 +03004657 i915_print_sseu_info(m, false, &sseu);
Jeff McGee7f992ab2015-02-13 10:27:55 -06004658
Jeff McGee38732182015-02-13 10:27:54 -06004659 return 0;
4660}
4661
Ben Widawsky6d794d42011-04-25 11:25:56 -07004662static int i915_forcewake_open(struct inode *inode, struct file *file)
4663{
Chris Wilsond7a133d2017-09-07 14:44:41 +01004664 struct drm_i915_private *i915 = inode->i_private;
Ben Widawsky6d794d42011-04-25 11:25:56 -07004665
Chris Wilsond7a133d2017-09-07 14:44:41 +01004666 if (INTEL_GEN(i915) < 6)
Ben Widawsky6d794d42011-04-25 11:25:56 -07004667 return 0;
4668
Chris Wilsond7a133d2017-09-07 14:44:41 +01004669 intel_runtime_pm_get(i915);
4670 intel_uncore_forcewake_user_get(i915);
Ben Widawsky6d794d42011-04-25 11:25:56 -07004671
4672 return 0;
4673}
4674
Ben Widawskyc43b5632012-04-16 14:07:40 -07004675static int i915_forcewake_release(struct inode *inode, struct file *file)
Ben Widawsky6d794d42011-04-25 11:25:56 -07004676{
Chris Wilsond7a133d2017-09-07 14:44:41 +01004677 struct drm_i915_private *i915 = inode->i_private;
Ben Widawsky6d794d42011-04-25 11:25:56 -07004678
Chris Wilsond7a133d2017-09-07 14:44:41 +01004679 if (INTEL_GEN(i915) < 6)
Ben Widawsky6d794d42011-04-25 11:25:56 -07004680 return 0;
4681
Chris Wilsond7a133d2017-09-07 14:44:41 +01004682 intel_uncore_forcewake_user_put(i915);
4683 intel_runtime_pm_put(i915);
Ben Widawsky6d794d42011-04-25 11:25:56 -07004684
4685 return 0;
4686}
4687
4688static const struct file_operations i915_forcewake_fops = {
4689 .owner = THIS_MODULE,
4690 .open = i915_forcewake_open,
4691 .release = i915_forcewake_release,
4692};
4693
Lyude317eaa92017-02-03 21:18:25 -05004694static int i915_hpd_storm_ctl_show(struct seq_file *m, void *data)
4695{
4696 struct drm_i915_private *dev_priv = m->private;
4697 struct i915_hotplug *hotplug = &dev_priv->hotplug;
4698
4699 seq_printf(m, "Threshold: %d\n", hotplug->hpd_storm_threshold);
4700 seq_printf(m, "Detected: %s\n",
4701 yesno(delayed_work_pending(&hotplug->reenable_work)));
4702
4703 return 0;
4704}
4705
4706static ssize_t i915_hpd_storm_ctl_write(struct file *file,
4707 const char __user *ubuf, size_t len,
4708 loff_t *offp)
4709{
4710 struct seq_file *m = file->private_data;
4711 struct drm_i915_private *dev_priv = m->private;
4712 struct i915_hotplug *hotplug = &dev_priv->hotplug;
4713 unsigned int new_threshold;
4714 int i;
4715 char *newline;
4716 char tmp[16];
4717
4718 if (len >= sizeof(tmp))
4719 return -EINVAL;
4720
4721 if (copy_from_user(tmp, ubuf, len))
4722 return -EFAULT;
4723
4724 tmp[len] = '\0';
4725
4726 /* Strip newline, if any */
4727 newline = strchr(tmp, '\n');
4728 if (newline)
4729 *newline = '\0';
4730
4731 if (strcmp(tmp, "reset") == 0)
4732 new_threshold = HPD_STORM_DEFAULT_THRESHOLD;
4733 else if (kstrtouint(tmp, 10, &new_threshold) != 0)
4734 return -EINVAL;
4735
4736 if (new_threshold > 0)
4737 DRM_DEBUG_KMS("Setting HPD storm detection threshold to %d\n",
4738 new_threshold);
4739 else
4740 DRM_DEBUG_KMS("Disabling HPD storm detection\n");
4741
4742 spin_lock_irq(&dev_priv->irq_lock);
4743 hotplug->hpd_storm_threshold = new_threshold;
4744 /* Reset the HPD storm stats so we don't accidentally trigger a storm */
4745 for_each_hpd_pin(i)
4746 hotplug->stats[i].count = 0;
4747 spin_unlock_irq(&dev_priv->irq_lock);
4748
4749 /* Re-enable hpd immediately if we were in an irq storm */
4750 flush_delayed_work(&dev_priv->hotplug.reenable_work);
4751
4752 return len;
4753}
4754
4755static int i915_hpd_storm_ctl_open(struct inode *inode, struct file *file)
4756{
4757 return single_open(file, i915_hpd_storm_ctl_show, inode->i_private);
4758}
4759
4760static const struct file_operations i915_hpd_storm_ctl_fops = {
4761 .owner = THIS_MODULE,
4762 .open = i915_hpd_storm_ctl_open,
4763 .read = seq_read,
4764 .llseek = seq_lseek,
4765 .release = single_release,
4766 .write = i915_hpd_storm_ctl_write
4767};
4768
Lespiau, Damien06c5bf82013-10-17 19:09:56 +01004769static const struct drm_info_list i915_debugfs_list[] = {
Chris Wilson311bd682011-01-13 19:06:50 +00004770 {"i915_capabilities", i915_capabilities, 0},
Chris Wilson73aa8082010-09-30 11:46:12 +01004771 {"i915_gem_objects", i915_gem_object_info, 0},
Chris Wilson08c18322011-01-10 00:00:24 +00004772 {"i915_gem_gtt", i915_gem_gtt_info, 0},
Chris Wilson6d2b88852013-08-07 18:30:54 +01004773 {"i915_gem_stolen", i915_gem_stolen_list_info },
Ben Gamari20172632009-02-17 20:08:50 -05004774 {"i915_gem_seqno", i915_gem_seqno_info, 0},
Chris Wilsona6172a82009-02-11 14:26:38 +00004775 {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05004776 {"i915_gem_interrupt", i915_interrupt_info, 0},
Brad Volkin493018d2014-12-11 12:13:08 -08004777 {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0},
Dave Gordon8b417c22015-08-12 15:43:44 +01004778 {"i915_guc_info", i915_guc_info, 0},
Alex Daifdf5d352015-08-12 15:43:37 +01004779 {"i915_guc_load_status", i915_guc_load_status_info, 0},
Alex Dai4c7e77f2015-08-12 15:43:40 +01004780 {"i915_guc_log_dump", i915_guc_log_dump, 0},
Daniele Ceraolo Spurioac58d2a2017-05-22 10:50:28 -07004781 {"i915_guc_load_err_log_dump", i915_guc_log_dump, 0, (void *)1},
Oscar Mateoa8b93702017-05-10 15:04:51 +00004782 {"i915_guc_stage_pool", i915_guc_stage_pool, 0},
Anusha Srivatsa0509ead2017-01-18 08:05:56 -08004783 {"i915_huc_load_status", i915_huc_load_status_info, 0},
Deepak Sadb4bd12014-03-31 11:30:02 +05304784 {"i915_frequency_info", i915_frequency_info, 0},
Chris Wilsonf6544492015-01-26 18:03:04 +02004785 {"i915_hangcheck_info", i915_hangcheck_info, 0},
Michel Thierry061d06a2017-06-20 10:57:49 +01004786 {"i915_reset_info", i915_reset_info, 0},
Jesse Barnesf97108d2010-01-29 11:27:07 -08004787 {"i915_drpc_info", i915_drpc_info, 0},
Jesse Barnes7648fa92010-05-20 14:28:11 -07004788 {"i915_emon_status", i915_emon_status, 0},
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07004789 {"i915_ring_freq_table", i915_ring_freq_table, 0},
Daniel Vetter9a851782015-06-18 10:30:22 +02004790 {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0},
Jesse Barnesb5e50c32010-02-05 12:42:41 -08004791 {"i915_fbc_status", i915_fbc_status, 0},
Paulo Zanoni92d44622013-05-31 16:33:24 -03004792 {"i915_ips_status", i915_ips_status, 0},
Jesse Barnes4a9bef32010-02-05 12:47:35 -08004793 {"i915_sr_status", i915_sr_status, 0},
Chris Wilson44834a62010-08-19 16:09:23 +01004794 {"i915_opregion", i915_opregion, 0},
Jani Nikulaada8f952015-12-15 13:17:12 +02004795 {"i915_vbt", i915_vbt, 0},
Chris Wilson37811fc2010-08-25 22:45:57 +01004796 {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
Ben Widawskye76d3632011-03-19 18:14:29 -07004797 {"i915_context_status", i915_context_status, 0},
Ben Widawskyc0ab1ae92014-08-07 13:24:26 +01004798 {"i915_dump_lrc", i915_dump_lrc, 0},
Mika Kuoppalaf65367b2015-01-16 11:34:42 +02004799 {"i915_forcewake_domains", i915_forcewake_domains, 0},
Daniel Vetterea16a3c2011-12-14 13:57:16 +01004800 {"i915_swizzle_info", i915_swizzle_info, 0},
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01004801 {"i915_ppgtt_info", i915_ppgtt_info, 0},
Ben Widawsky63573eb2013-07-04 11:02:07 -07004802 {"i915_llc", i915_llc, 0},
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03004803 {"i915_edp_psr_status", i915_edp_psr_status, 0},
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02004804 {"i915_sink_crc_eDP1", i915_sink_crc, 0},
Jesse Barnesec013e72013-08-20 10:29:23 +01004805 {"i915_energy_uJ", i915_energy_uJ, 0},
Damien Lespiau6455c872015-06-04 18:23:57 +01004806 {"i915_runtime_pm_status", i915_runtime_pm_status, 0},
Imre Deak1da51582013-11-25 17:15:35 +02004807 {"i915_power_domain_info", i915_power_domain_info, 0},
Damien Lespiaub7cec662015-10-27 14:47:01 +02004808 {"i915_dmc_info", i915_dmc_info, 0},
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08004809 {"i915_display_info", i915_display_info, 0},
Chris Wilson1b365952016-10-04 21:11:31 +01004810 {"i915_engine_info", i915_engine_info, 0},
Chris Wilsonc5418a82017-10-13 21:26:19 +01004811 {"i915_shrinker_info", i915_shrinker_info, 0},
Ben Widawskye04934c2014-06-30 09:53:42 -07004812 {"i915_semaphore_status", i915_semaphore_status, 0},
Daniel Vetter728e29d2014-06-25 22:01:53 +03004813 {"i915_shared_dplls_info", i915_shared_dplls_info, 0},
Dave Airlie11bed952014-05-12 15:22:27 +10004814 {"i915_dp_mst_info", i915_dp_mst_info, 0},
Damien Lespiau1ed1ef92014-08-30 16:50:59 +01004815 {"i915_wa_registers", i915_wa_registers, 0},
Damien Lespiauc5511e42014-11-04 17:06:51 +00004816 {"i915_ddb_info", i915_ddb_info, 0},
Jeff McGee38732182015-02-13 10:27:54 -06004817 {"i915_sseu_status", i915_sseu_status, 0},
Vandana Kannana54746e2015-03-03 20:53:10 +05304818 {"i915_drrs_status", i915_drrs_status, 0},
Chris Wilson1854d5c2015-04-07 16:20:32 +01004819 {"i915_rps_boost_info", i915_rps_boost_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05004820};
Ben Gamari27c202a2009-07-01 22:26:52 -04004821#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
Ben Gamari20172632009-02-17 20:08:50 -05004822
Lespiau, Damien06c5bf82013-10-17 19:09:56 +01004823static const struct i915_debugfs_files {
Daniel Vetter34b96742013-07-04 20:49:44 +02004824 const char *name;
4825 const struct file_operations *fops;
4826} i915_debugfs_files[] = {
4827 {"i915_wedged", &i915_wedged_fops},
4828 {"i915_max_freq", &i915_max_freq_fops},
4829 {"i915_min_freq", &i915_min_freq_fops},
4830 {"i915_cache_sharing", &i915_cache_sharing_fops},
Chris Wilson094f9a52013-09-25 17:34:55 +01004831 {"i915_ring_missed_irq", &i915_ring_missed_irq_fops},
4832 {"i915_ring_test_irq", &i915_ring_test_irq_fops},
Daniel Vetter34b96742013-07-04 20:49:44 +02004833 {"i915_gem_drop_caches", &i915_drop_caches_fops},
Chris Wilson98a2f412016-10-12 10:05:18 +01004834#if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR)
Daniel Vetter34b96742013-07-04 20:49:44 +02004835 {"i915_error_state", &i915_error_state_fops},
Chris Wilson5a4c6f12017-02-14 16:46:11 +00004836 {"i915_gpu_info", &i915_gpu_info_fops},
Chris Wilson98a2f412016-10-12 10:05:18 +01004837#endif
Daniel Vetter34b96742013-07-04 20:49:44 +02004838 {"i915_next_seqno", &i915_next_seqno_fops},
Damien Lespiaubd9db022013-10-15 18:55:36 +01004839 {"i915_display_crc_ctl", &i915_display_crc_ctl_fops},
Ville Syrjälä369a1342014-01-22 14:36:08 +02004840 {"i915_pri_wm_latency", &i915_pri_wm_latency_fops},
4841 {"i915_spr_wm_latency", &i915_spr_wm_latency_fops},
4842 {"i915_cur_wm_latency", &i915_cur_wm_latency_fops},
Ville Syrjälä4127dc42017-06-06 15:44:12 +03004843 {"i915_fbc_false_color", &i915_fbc_false_color_fops},
Todd Previteeb3394fa2015-04-18 00:04:19 -07004844 {"i915_dp_test_data", &i915_displayport_test_data_fops},
4845 {"i915_dp_test_type", &i915_displayport_test_type_fops},
Sagar Arun Kamble685534e2016-10-12 21:54:41 +05304846 {"i915_dp_test_active", &i915_displayport_test_active_fops},
Lyude317eaa92017-02-03 21:18:25 -05004847 {"i915_guc_log_control", &i915_guc_log_control_fops},
Kumar, Maheshd2d4f392017-08-17 19:15:29 +05304848 {"i915_hpd_storm_ctl", &i915_hpd_storm_ctl_fops},
4849 {"i915_ipc_status", &i915_ipc_status_fops}
Daniel Vetter34b96742013-07-04 20:49:44 +02004850};
4851
Chris Wilson1dac8912016-06-24 14:00:17 +01004852int i915_debugfs_register(struct drm_i915_private *dev_priv)
Ben Gamari20172632009-02-17 20:08:50 -05004853{
Chris Wilson91c8a322016-07-05 10:40:23 +01004854 struct drm_minor *minor = dev_priv->drm.primary;
Noralf Trønnesb05eeb02017-01-26 23:56:21 +01004855 struct dentry *ent;
Daniel Vetter34b96742013-07-04 20:49:44 +02004856 int ret, i;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01004857
Noralf Trønnesb05eeb02017-01-26 23:56:21 +01004858 ent = debugfs_create_file("i915_forcewake_user", S_IRUSR,
4859 minor->debugfs_root, to_i915(minor->dev),
4860 &i915_forcewake_fops);
4861 if (!ent)
4862 return -ENOMEM;
Daniel Vetter6a9c3082011-12-14 13:57:11 +01004863
Tomeu Vizoso731035f2016-12-12 13:29:48 +01004864 ret = intel_pipe_crc_create(minor);
4865 if (ret)
4866 return ret;
Damien Lespiau07144422013-10-15 18:55:40 +01004867
Daniel Vetter34b96742013-07-04 20:49:44 +02004868 for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
Noralf Trønnesb05eeb02017-01-26 23:56:21 +01004869 ent = debugfs_create_file(i915_debugfs_files[i].name,
4870 S_IRUGO | S_IWUSR,
4871 minor->debugfs_root,
4872 to_i915(minor->dev),
Daniel Vetter34b96742013-07-04 20:49:44 +02004873 i915_debugfs_files[i].fops);
Noralf Trønnesb05eeb02017-01-26 23:56:21 +01004874 if (!ent)
4875 return -ENOMEM;
Daniel Vetter34b96742013-07-04 20:49:44 +02004876 }
Mika Kuoppala40633212012-12-04 15:12:00 +02004877
Ben Gamari27c202a2009-07-01 22:26:52 -04004878 return drm_debugfs_create_files(i915_debugfs_list,
4879 I915_DEBUGFS_ENTRIES,
Ben Gamari20172632009-02-17 20:08:50 -05004880 minor->debugfs_root, minor);
4881}
4882
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004883struct dpcd_block {
4884 /* DPCD dump start address. */
4885 unsigned int offset;
4886 /* DPCD dump end address, inclusive. If unset, .size will be used. */
4887 unsigned int end;
4888 /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */
4889 size_t size;
4890 /* Only valid for eDP. */
4891 bool edp;
4892};
4893
4894static const struct dpcd_block i915_dpcd_debug[] = {
4895 { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE },
4896 { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS },
4897 { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 },
4898 { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET },
4899 { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 },
4900 { .offset = DP_SET_POWER },
4901 { .offset = DP_EDP_DPCD_REV },
4902 { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 },
4903 { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB },
4904 { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET },
4905};
4906
4907static int i915_dpcd_show(struct seq_file *m, void *data)
4908{
4909 struct drm_connector *connector = m->private;
4910 struct intel_dp *intel_dp =
4911 enc_to_intel_dp(&intel_attached_encoder(connector)->base);
4912 uint8_t buf[16];
4913 ssize_t err;
4914 int i;
4915
Mika Kuoppala5c1a8872015-05-15 13:09:21 +03004916 if (connector->status != connector_status_connected)
4917 return -ENODEV;
4918
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004919 for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) {
4920 const struct dpcd_block *b = &i915_dpcd_debug[i];
4921 size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1);
4922
4923 if (b->edp &&
4924 connector->connector_type != DRM_MODE_CONNECTOR_eDP)
4925 continue;
4926
4927 /* low tech for now */
4928 if (WARN_ON(size > sizeof(buf)))
4929 continue;
4930
4931 err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size);
4932 if (err <= 0) {
4933 DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n",
4934 size, b->offset, err);
4935 continue;
4936 }
4937
4938 seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf);
kbuild test robotb3f9d7d2015-04-16 18:34:06 +08004939 }
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004940
4941 return 0;
4942}
4943
4944static int i915_dpcd_open(struct inode *inode, struct file *file)
4945{
4946 return single_open(file, i915_dpcd_show, inode->i_private);
4947}
4948
4949static const struct file_operations i915_dpcd_fops = {
4950 .owner = THIS_MODULE,
4951 .open = i915_dpcd_open,
4952 .read = seq_read,
4953 .llseek = seq_lseek,
4954 .release = single_release,
4955};
4956
David Weinehallecbd6782016-08-23 12:23:56 +03004957static int i915_panel_show(struct seq_file *m, void *data)
4958{
4959 struct drm_connector *connector = m->private;
4960 struct intel_dp *intel_dp =
4961 enc_to_intel_dp(&intel_attached_encoder(connector)->base);
4962
4963 if (connector->status != connector_status_connected)
4964 return -ENODEV;
4965
4966 seq_printf(m, "Panel power up delay: %d\n",
4967 intel_dp->panel_power_up_delay);
4968 seq_printf(m, "Panel power down delay: %d\n",
4969 intel_dp->panel_power_down_delay);
4970 seq_printf(m, "Backlight on delay: %d\n",
4971 intel_dp->backlight_on_delay);
4972 seq_printf(m, "Backlight off delay: %d\n",
4973 intel_dp->backlight_off_delay);
4974
4975 return 0;
4976}
4977
4978static int i915_panel_open(struct inode *inode, struct file *file)
4979{
4980 return single_open(file, i915_panel_show, inode->i_private);
4981}
4982
4983static const struct file_operations i915_panel_fops = {
4984 .owner = THIS_MODULE,
4985 .open = i915_panel_open,
4986 .read = seq_read,
4987 .llseek = seq_lseek,
4988 .release = single_release,
4989};
4990
Jani Nikulaaa7471d2015-04-01 11:15:21 +03004991/**
4992 * i915_debugfs_connector_add - add i915 specific connector debugfs files
4993 * @connector: pointer to a registered drm_connector
4994 *
4995 * Cleanup will be done by drm_connector_unregister() through a call to
4996 * drm_debugfs_connector_remove().
4997 *
4998 * Returns 0 on success, negative error codes on error.
4999 */
5000int i915_debugfs_connector_add(struct drm_connector *connector)
5001{
5002 struct dentry *root = connector->debugfs_entry;
5003
5004 /* The connector must have been registered beforehands. */
5005 if (!root)
5006 return -ENODEV;
5007
5008 if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
5009 connector->connector_type == DRM_MODE_CONNECTOR_eDP)
David Weinehallecbd6782016-08-23 12:23:56 +03005010 debugfs_create_file("i915_dpcd", S_IRUGO, root,
5011 connector, &i915_dpcd_fops);
5012
5013 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP)
5014 debugfs_create_file("i915_panel_timings", S_IRUGO, root,
5015 connector, &i915_panel_fops);
Jani Nikulaaa7471d2015-04-01 11:15:21 +03005016
5017 return 0;
5018}