127c202adSBen Gamari /*
227c202adSBen Gamari * Copyright © 2008 Intel Corporation
327c202adSBen Gamari *
427c202adSBen Gamari * Permission is hereby granted, free of charge, to any person obtaining a
527c202adSBen Gamari * copy of this software and associated documentation files (the "Software"),
627c202adSBen Gamari * to deal in the Software without restriction, including without limitation
727c202adSBen Gamari * the rights to use, copy, modify, merge, publish, distribute, sublicense,
827c202adSBen Gamari * and/or sell copies of the Software, and to permit persons to whom the
927c202adSBen Gamari * Software is furnished to do so, subject to the following conditions:
1027c202adSBen Gamari *
1127c202adSBen Gamari * The above copyright notice and this permission notice (including the next
1227c202adSBen Gamari * paragraph) shall be included in all copies or substantial portions of the
1327c202adSBen Gamari * Software.
1427c202adSBen Gamari *
1527c202adSBen Gamari * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1627c202adSBen Gamari * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1727c202adSBen Gamari * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1827c202adSBen Gamari * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1927c202adSBen Gamari * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2027c202adSBen Gamari * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2127c202adSBen Gamari * IN THE SOFTWARE.
2227c202adSBen Gamari *
2327c202adSBen Gamari * Authors:
2427c202adSBen Gamari * Eric Anholt <eric@anholt.net>
2527c202adSBen Gamari * Keith Packard <keithp@keithp.com>
2627c202adSBen Gamari *
2727c202adSBen Gamari */
2827c202adSBen Gamari
29d92a8cfcSPeter Zijlstra #include <linux/sched/mm.h>
3098afa316SJani Nikula #include <linux/sort.h>
3101fabda8SLucas De Marchi #include <linux/string_helpers.h>
3298afa316SJani Nikula
337fa043eaSDave Airlie #include <linux/debugfs.h>
34fcd70cd3SDaniel Vetter #include <drm/drm_debugfs.h>
35379bc100SJani Nikula
367a61a6aaSJouni Högander #include "display/intel_display_params.h"
377a61a6aaSJouni Högander
3810be98a7SChris Wilson #include "gem/i915_gem_context.h"
39d0c56031SLucas De Marchi #include "gt/intel_gt.h"
4016e87459SChris Wilson #include "gt/intel_gt_buffer_pool.h"
419c878557SChris Wilson #include "gt/intel_gt_clock_utils.h"
4282a149a6SAndi Shyti #include "gt/intel_gt_debugfs.h"
43c7302f20SChris Wilson #include "gt/intel_gt_pm.h"
44d0c56031SLucas De Marchi #include "gt/intel_gt_pm_debugfs.h"
450d6419e9SMatt Roper #include "gt/intel_gt_regs.h"
4666101975SChris Wilson #include "gt/intel_gt_requests.h"
47c1132367SAndi Shyti #include "gt/intel_rc6.h"
48d0c56031SLucas De Marchi #include "gt/intel_reset.h"
493e7abf81SAndi Shyti #include "gt/intel_rps.h"
50a00eda7dSDaniele Ceraolo Spurio #include "gt/intel_sseu_debugfs.h"
51112ed2d3SChris Wilson
522126d3e9SJani Nikula #include "i915_debugfs.h"
53c43c5a88SJani Nikula #include "i915_debugfs_params.h"
54a7f46d5bSTvrtko Ursulin #include "i915_driver.h"
554fca5198SJani Nikula #include "i915_gpu_error.h"
56440e2b3dSJani Nikula #include "i915_irq.h"
57476f62b8SJani Nikula #include "i915_reg.h"
58da7ac715STvrtko Ursulin #include "i915_scheduler.h"
59e30e6c7bSMatt Roper #include "intel_mchbar_regs.h"
609f58892eSChris Wilson
node_to_i915(struct drm_info_node * node)6136cdd013SDavid Weinehall static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node)
6236cdd013SDavid Weinehall {
6336cdd013SDavid Weinehall return to_i915(node->minor->dev);
6436cdd013SDavid Weinehall }
6536cdd013SDavid Weinehall
i915_capabilities(struct seq_file * m,void * data)6670d39fe4SChris Wilson static int i915_capabilities(struct seq_file *m, void *data)
6770d39fe4SChris Wilson {
6872404978SChris Wilson struct drm_i915_private *i915 = node_to_i915(m->private);
69*1c8f80c2SJani Nikula struct intel_display *display = &i915->display;
70a8c9b849SMichal Wajdeczko struct drm_printer p = drm_seq_file_printer(m);
7170d39fe4SChris Wilson
7272404978SChris Wilson seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(i915));
73418e3cd8SChris Wilson
74c7d3c844SJani Nikula intel_device_info_print(INTEL_INFO(i915), RUNTIME_INFO(i915), &p);
75cca08469STvrtko Ursulin i915_print_iommu_status(i915, &p);
762cbc876dSMichał Winiarski intel_gt_info_print(&to_gt(i915)->info, &p);
7772404978SChris Wilson intel_driver_caps_print(&i915->caps, &p);
7870d39fe4SChris Wilson
79418e3cd8SChris Wilson kernel_param_lock(THIS_MODULE);
808a25c4beSJani Nikula i915_params_dump(&i915->params, &p);
81*1c8f80c2SJani Nikula intel_display_params_dump(display, &p);
82418e3cd8SChris Wilson kernel_param_unlock(THIS_MODULE);
83418e3cd8SChris Wilson
8470d39fe4SChris Wilson return 0;
8570d39fe4SChris Wilson }
8627c202adSBen Gamari
get_tiling_flag(struct drm_i915_gem_object * obj)87a7363de7SImre Deak static char get_tiling_flag(struct drm_i915_gem_object *obj)
8827c202adSBen Gamari {
893e510a8eSChris Wilson switch (i915_gem_object_get_tiling(obj)) {
9027c202adSBen Gamari default:
91be12a86bSTvrtko Ursulin case I915_TILING_NONE: return ' ';
92be12a86bSTvrtko Ursulin case I915_TILING_X: return 'X';
93be12a86bSTvrtko Ursulin case I915_TILING_Y: return 'Y';
9427c202adSBen Gamari }
9527c202adSBen Gamari }
9627c202adSBen Gamari
get_global_flag(struct drm_i915_gem_object * obj)97a7363de7SImre Deak static char get_global_flag(struct drm_i915_gem_object *obj)
981d693bccSBen Widawsky {
99b7d151baSChris Wilson return READ_ONCE(obj->userfault_count) ? 'g' : ' ';
100be12a86bSTvrtko Ursulin }
101be12a86bSTvrtko Ursulin
get_pin_mapped_flag(struct drm_i915_gem_object * obj)102a7363de7SImre Deak static char get_pin_mapped_flag(struct drm_i915_gem_object *obj)
103be12a86bSTvrtko Ursulin {
104a4f5ea64SChris Wilson return obj->mm.mapping ? 'M' : ' ';
1051d693bccSBen Widawsky }
1061d693bccSBen Widawsky
1077393b7eeSMatthew Auld static const char *
stringify_page_sizes(unsigned int page_sizes,char * buf,size_t len)1087393b7eeSMatthew Auld stringify_page_sizes(unsigned int page_sizes, char *buf, size_t len)
1097393b7eeSMatthew Auld {
1107393b7eeSMatthew Auld size_t x = 0;
1117393b7eeSMatthew Auld
1127393b7eeSMatthew Auld switch (page_sizes) {
1137393b7eeSMatthew Auld case 0:
1147393b7eeSMatthew Auld return "";
1157393b7eeSMatthew Auld case I915_GTT_PAGE_SIZE_4K:
1167393b7eeSMatthew Auld return "4K";
1177393b7eeSMatthew Auld case I915_GTT_PAGE_SIZE_64K:
1187393b7eeSMatthew Auld return "64K";
1197393b7eeSMatthew Auld case I915_GTT_PAGE_SIZE_2M:
1207393b7eeSMatthew Auld return "2M";
1217393b7eeSMatthew Auld default:
1227393b7eeSMatthew Auld if (!buf)
1237393b7eeSMatthew Auld return "M";
1247393b7eeSMatthew Auld
1257393b7eeSMatthew Auld if (page_sizes & I915_GTT_PAGE_SIZE_2M)
1267393b7eeSMatthew Auld x += snprintf(buf + x, len - x, "2M, ");
1277393b7eeSMatthew Auld if (page_sizes & I915_GTT_PAGE_SIZE_64K)
1287393b7eeSMatthew Auld x += snprintf(buf + x, len - x, "64K, ");
1297393b7eeSMatthew Auld if (page_sizes & I915_GTT_PAGE_SIZE_4K)
1307393b7eeSMatthew Auld x += snprintf(buf + x, len - x, "4K, ");
1317393b7eeSMatthew Auld buf[x-2] = '\0';
1327393b7eeSMatthew Auld
1337393b7eeSMatthew Auld return buf;
1347393b7eeSMatthew Auld }
1357393b7eeSMatthew Auld }
1367393b7eeSMatthew Auld
stringify_vma_type(const struct i915_vma * vma)1370f926e5cSImre Deak static const char *stringify_vma_type(const struct i915_vma *vma)
1380f926e5cSImre Deak {
1390f926e5cSImre Deak if (i915_vma_is_ggtt(vma))
1400f926e5cSImre Deak return "ggtt";
1410f926e5cSImre Deak
1420f926e5cSImre Deak if (i915_vma_is_dpt(vma))
1430f926e5cSImre Deak return "dpt";
1440f926e5cSImre Deak
1450f926e5cSImre Deak return "ppgtt";
1460f926e5cSImre Deak }
1470f926e5cSImre Deak
i915_cache_level_str(struct drm_i915_gem_object * obj)1489275277dSFei Yang static const char *i915_cache_level_str(struct drm_i915_gem_object *obj)
14974fc5954SJani Nikula {
1509275277dSFei Yang struct drm_i915_private *i915 = obj_to_i915(obj);
1519275277dSFei Yang
15284bf82f4SHarish Chegondi if (IS_GFX_GT_IP_RANGE(to_gt(i915), IP_VER(12, 70), IP_VER(12, 74))) {
1539275277dSFei Yang switch (obj->pat_index) {
1549275277dSFei Yang case 0: return " WB";
1559275277dSFei Yang case 1: return " WT";
1569275277dSFei Yang case 2: return " UC";
1579275277dSFei Yang case 3: return " WB (1-Way Coh)";
1589275277dSFei Yang case 4: return " WB (2-Way Coh)";
1599275277dSFei Yang default: return " not defined";
1609275277dSFei Yang }
1619275277dSFei Yang } else if (GRAPHICS_VER(i915) >= 12) {
1629275277dSFei Yang switch (obj->pat_index) {
1639275277dSFei Yang case 0: return " WB";
1649275277dSFei Yang case 1: return " WC";
1659275277dSFei Yang case 2: return " WT";
1669275277dSFei Yang case 3: return " UC";
1679275277dSFei Yang default: return " not defined";
1689275277dSFei Yang }
1699275277dSFei Yang } else {
1709275277dSFei Yang switch (obj->pat_index) {
1719275277dSFei Yang case 0: return " UC";
1729275277dSFei Yang case 1: return HAS_LLC(i915) ?
1739275277dSFei Yang " LLC" : " snooped";
1749275277dSFei Yang case 2: return " L3+LLC";
1759275277dSFei Yang case 3: return " WT";
1769275277dSFei Yang default: return " not defined";
1779275277dSFei Yang }
17874fc5954SJani Nikula }
17974fc5954SJani Nikula }
18074fc5954SJani Nikula
181926b005cSJani Nikula void
i915_debugfs_describe_obj(struct seq_file * m,struct drm_i915_gem_object * obj)182926b005cSJani Nikula i915_debugfs_describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
18337811fccSChris Wilson {
1841d693bccSBen Widawsky struct i915_vma *vma;
185d7f46fc4SBen Widawsky int pin_count = 0;
186d7f46fc4SBen Widawsky
1875a90606dSChris Wilson seq_printf(m, "%pK: %c%c%c %8zdKiB %02x %02x %s%s%s",
18837811fccSChris Wilson &obj->base,
18937811fccSChris Wilson get_tiling_flag(obj),
1901d693bccSBen Widawsky get_global_flag(obj),
191be12a86bSTvrtko Ursulin get_pin_mapped_flag(obj),
192a05a5862SEric Anholt obj->base.size / 1024,
193c0a51fd0SChristian König obj->read_domains,
194c0a51fd0SChristian König obj->write_domain,
1959275277dSFei Yang i915_cache_level_str(obj),
196a4f5ea64SChris Wilson obj->mm.dirty ? " dirty" : "",
197a4f5ea64SChris Wilson obj->mm.madv == I915_MADV_DONTNEED ? " purgeable" : "");
19837811fccSChris Wilson if (obj->base.name)
19937811fccSChris Wilson seq_printf(m, " (name: %d)", obj->base.name);
2000cf289bdSChris Wilson
2010cf289bdSChris Wilson spin_lock(&obj->vma.lock);
202528cbd17SChris Wilson list_for_each_entry(vma, &obj->vma.list, obj_link) {
20315717de2SChris Wilson if (!drm_mm_node_allocated(&vma->node))
20415717de2SChris Wilson continue;
20515717de2SChris Wilson
2060cf289bdSChris Wilson spin_unlock(&obj->vma.lock);
2070cf289bdSChris Wilson
2080cf289bdSChris Wilson if (i915_vma_is_pinned(vma))
2090cf289bdSChris Wilson pin_count++;
2100cf289bdSChris Wilson
2110f926e5cSImre Deak seq_printf(m, " (%s offset: %08llx, size: %08llx, pages: %s",
2120f926e5cSImre Deak stringify_vma_type(vma),
2138e4ee5e8SChris Wilson i915_vma_offset(vma), i915_vma_size(vma),
21439a2bd34SThomas Hellström stringify_page_sizes(vma->resource->page_sizes_gtt,
21539a2bd34SThomas Hellström NULL, 0));
2160f926e5cSImre Deak if (i915_vma_is_ggtt(vma) || i915_vma_is_dpt(vma)) {
2173bb6a442SNiranjana Vishwanathapura switch (vma->gtt_view.type) {
2183bb6a442SNiranjana Vishwanathapura case I915_GTT_VIEW_NORMAL:
21921976853SChris Wilson seq_puts(m, ", normal");
22021976853SChris Wilson break;
22121976853SChris Wilson
2223bb6a442SNiranjana Vishwanathapura case I915_GTT_VIEW_PARTIAL:
22321976853SChris Wilson seq_printf(m, ", partial [%08llx+%x]",
2243bb6a442SNiranjana Vishwanathapura vma->gtt_view.partial.offset << PAGE_SHIFT,
2253bb6a442SNiranjana Vishwanathapura vma->gtt_view.partial.size << PAGE_SHIFT);
22621976853SChris Wilson break;
22721976853SChris Wilson
2283bb6a442SNiranjana Vishwanathapura case I915_GTT_VIEW_ROTATED:
229a4606d45SImre Deak seq_printf(m, ", rotated [(%ux%u, src_stride=%u, dst_stride=%u, offset=%u), (%ux%u, src_stride=%u, dst_stride=%u, offset=%u)]",
2303bb6a442SNiranjana Vishwanathapura vma->gtt_view.rotated.plane[0].width,
2313bb6a442SNiranjana Vishwanathapura vma->gtt_view.rotated.plane[0].height,
2323bb6a442SNiranjana Vishwanathapura vma->gtt_view.rotated.plane[0].src_stride,
2333bb6a442SNiranjana Vishwanathapura vma->gtt_view.rotated.plane[0].dst_stride,
2343bb6a442SNiranjana Vishwanathapura vma->gtt_view.rotated.plane[0].offset,
2353bb6a442SNiranjana Vishwanathapura vma->gtt_view.rotated.plane[1].width,
2363bb6a442SNiranjana Vishwanathapura vma->gtt_view.rotated.plane[1].height,
2373bb6a442SNiranjana Vishwanathapura vma->gtt_view.rotated.plane[1].src_stride,
2383bb6a442SNiranjana Vishwanathapura vma->gtt_view.rotated.plane[1].dst_stride,
2393bb6a442SNiranjana Vishwanathapura vma->gtt_view.rotated.plane[1].offset);
24021976853SChris Wilson break;
24121976853SChris Wilson
2423bb6a442SNiranjana Vishwanathapura case I915_GTT_VIEW_REMAPPED:
243a4606d45SImre Deak seq_printf(m, ", remapped [(%ux%u, src_stride=%u, dst_stride=%u, offset=%u), (%ux%u, src_stride=%u, dst_stride=%u, offset=%u)]",
2443bb6a442SNiranjana Vishwanathapura vma->gtt_view.remapped.plane[0].width,
2453bb6a442SNiranjana Vishwanathapura vma->gtt_view.remapped.plane[0].height,
2463bb6a442SNiranjana Vishwanathapura vma->gtt_view.remapped.plane[0].src_stride,
2473bb6a442SNiranjana Vishwanathapura vma->gtt_view.remapped.plane[0].dst_stride,
2483bb6a442SNiranjana Vishwanathapura vma->gtt_view.remapped.plane[0].offset,
2493bb6a442SNiranjana Vishwanathapura vma->gtt_view.remapped.plane[1].width,
2503bb6a442SNiranjana Vishwanathapura vma->gtt_view.remapped.plane[1].height,
2513bb6a442SNiranjana Vishwanathapura vma->gtt_view.remapped.plane[1].src_stride,
2523bb6a442SNiranjana Vishwanathapura vma->gtt_view.remapped.plane[1].dst_stride,
2533bb6a442SNiranjana Vishwanathapura vma->gtt_view.remapped.plane[1].offset);
2541a74fc0bSVille Syrjälä break;
2551a74fc0bSVille Syrjälä
25621976853SChris Wilson default:
2573bb6a442SNiranjana Vishwanathapura MISSING_CASE(vma->gtt_view.type);
25821976853SChris Wilson break;
25921976853SChris Wilson }
26021976853SChris Wilson }
26149ef5294SChris Wilson if (vma->fence)
2623d6792cfSChris Wilson seq_printf(m, " , fence: %d", vma->fence->id);
2638d2fdc3fSTvrtko Ursulin seq_puts(m, ")");
2640cf289bdSChris Wilson
2650cf289bdSChris Wilson spin_lock(&obj->vma.lock);
2661d693bccSBen Widawsky }
2670cf289bdSChris Wilson spin_unlock(&obj->vma.lock);
2680cf289bdSChris Wilson
2690cf289bdSChris Wilson seq_printf(m, " (pinned x %d)", pin_count);
27041a9c75dSChris Wilson if (i915_gem_object_is_stolen(obj))
271440fd528SThierry Reding seq_printf(m, " (stolen: %08llx)", obj->stolen->start);
2725a90606dSChris Wilson if (i915_gem_object_is_framebuffer(obj))
2735a90606dSChris Wilson seq_printf(m, " (fb)");
27437811fccSChris Wilson }
27537811fccSChris Wilson
i915_gem_object_info(struct seq_file * m,void * data)27673aa808fSChris Wilson static int i915_gem_object_info(struct seq_file *m, void *data)
27773aa808fSChris Wilson {
278ecab9be1SChris Wilson struct drm_i915_private *i915 = node_to_i915(m->private);
2798c3363c6SMatthew Auld struct drm_printer p = drm_seq_file_printer(m);
28038f1cb68SLukasz Fiedorowicz struct intel_memory_region *mr;
28138f1cb68SLukasz Fiedorowicz enum intel_region_id id;
28273aa808fSChris Wilson
2831aff1903SChris Wilson seq_printf(m, "%u shrinkable [%u free] objects, %llu bytes\n",
284ecab9be1SChris Wilson i915->mm.shrink_count,
2851aff1903SChris Wilson atomic_read(&i915->mm.free_count),
286ecab9be1SChris Wilson i915->mm.shrink_memory);
28738f1cb68SLukasz Fiedorowicz for_each_memory_region(mr, i915, id)
2888c3363c6SMatthew Auld intel_memory_region_debug(mr, &p);
28973aa808fSChris Wilson
29073aa808fSChris Wilson return 0;
29173aa808fSChris Wilson }
29273aa808fSChris Wilson
i915_frequency_info(struct seq_file * m,void * unused)293adb4bd12SDeepak S static int i915_frequency_info(struct seq_file *m, void *unused)
294f97108d1SJesse Barnes {
295d0c56031SLucas De Marchi struct drm_i915_private *i915 = node_to_i915(m->private);
2962cbc876dSMichał Winiarski struct intel_gt *gt = to_gt(i915);
297d0c56031SLucas De Marchi struct drm_printer p = drm_seq_file_printer(m);
298c8c8fb33SPaulo Zanoni
299d0c56031SLucas De Marchi intel_gt_pm_frequency_dump(gt, &p);
3003b8d8d91SJesse Barnes
301bd0cef2aSZou Wei return 0;
302f97108d1SJesse Barnes }
303f97108d1SJesse Barnes
swizzle_string(unsigned swizzle)304ea16a3cdSDaniel Vetter static const char *swizzle_string(unsigned swizzle)
305ea16a3cdSDaniel Vetter {
306ea16a3cdSDaniel Vetter switch (swizzle) {
307ea16a3cdSDaniel Vetter case I915_BIT_6_SWIZZLE_NONE:
308ea16a3cdSDaniel Vetter return "none";
309ea16a3cdSDaniel Vetter case I915_BIT_6_SWIZZLE_9:
310ea16a3cdSDaniel Vetter return "bit9";
311ea16a3cdSDaniel Vetter case I915_BIT_6_SWIZZLE_9_10:
312ea16a3cdSDaniel Vetter return "bit9/bit10";
313ea16a3cdSDaniel Vetter case I915_BIT_6_SWIZZLE_9_11:
314ea16a3cdSDaniel Vetter return "bit9/bit11";
315ea16a3cdSDaniel Vetter case I915_BIT_6_SWIZZLE_9_10_11:
316ea16a3cdSDaniel Vetter return "bit9/bit10/bit11";
317ea16a3cdSDaniel Vetter case I915_BIT_6_SWIZZLE_9_17:
318ea16a3cdSDaniel Vetter return "bit9/bit17";
319ea16a3cdSDaniel Vetter case I915_BIT_6_SWIZZLE_9_10_17:
320ea16a3cdSDaniel Vetter return "bit9/bit10/bit17";
321ea16a3cdSDaniel Vetter case I915_BIT_6_SWIZZLE_UNKNOWN:
3228a168ca7SMasanari Iida return "unknown";
323ea16a3cdSDaniel Vetter }
324ea16a3cdSDaniel Vetter
325ea16a3cdSDaniel Vetter return "bug";
326ea16a3cdSDaniel Vetter }
327ea16a3cdSDaniel Vetter
i915_swizzle_info(struct seq_file * m,void * data)328ea16a3cdSDaniel Vetter static int i915_swizzle_info(struct seq_file *m, void *data)
329ea16a3cdSDaniel Vetter {
33036cdd013SDavid Weinehall struct drm_i915_private *dev_priv = node_to_i915(m->private);
3314f5fd91fSTvrtko Ursulin struct intel_uncore *uncore = &dev_priv->uncore;
332a037121cSChris Wilson intel_wakeref_t wakeref;
333ea16a3cdSDaniel Vetter
334ea16a3cdSDaniel Vetter seq_printf(m, "bit6 swizzle for X-tiling = %s\n",
335204129a2SMichał Winiarski swizzle_string(to_gt(dev_priv)->ggtt->bit_6_swizzle_x));
336ea16a3cdSDaniel Vetter seq_printf(m, "bit6 swizzle for Y-tiling = %s\n",
337204129a2SMichał Winiarski swizzle_string(to_gt(dev_priv)->ggtt->bit_6_swizzle_y));
338ea16a3cdSDaniel Vetter
33995086cb9SJani Nikula if (dev_priv->gem_quirks & GEM_QUIRK_PIN_SWIZZLED_PAGES)
3401fe541ccSLucas De Marchi seq_puts(m, "L-shaped memory detected\n");
3411fe541ccSLucas De Marchi
3421fe541ccSLucas De Marchi /* On BDW+, swizzling is not used. See detect_bit_6_swizzle() */
343651e7d48SLucas De Marchi if (GRAPHICS_VER(dev_priv) >= 8 || IS_VALLEYVIEW(dev_priv))
3441fe541ccSLucas De Marchi return 0;
3451fe541ccSLucas De Marchi
3461fe541ccSLucas De Marchi wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm);
3471fe541ccSLucas De Marchi
348651e7d48SLucas De Marchi if (IS_GRAPHICS_VER(dev_priv, 3, 4)) {
349ea16a3cdSDaniel Vetter seq_printf(m, "DDC = 0x%08x\n",
3504f5fd91fSTvrtko Ursulin intel_uncore_read(uncore, DCC));
351656bfa3aSDaniel Vetter seq_printf(m, "DDC2 = 0x%08x\n",
3524f5fd91fSTvrtko Ursulin intel_uncore_read(uncore, DCC2));
353ea16a3cdSDaniel Vetter seq_printf(m, "C0DRB3 = 0x%04x\n",
354924ad0e8SVille Syrjälä intel_uncore_read16(uncore, C0DRB3_BW));
355ea16a3cdSDaniel Vetter seq_printf(m, "C1DRB3 = 0x%04x\n",
356924ad0e8SVille Syrjälä intel_uncore_read16(uncore, C1DRB3_BW));
357d70cc074SLucas De Marchi } else if (GRAPHICS_VER(dev_priv) >= 6) {
3583fa7d235SDaniel Vetter seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n",
3594f5fd91fSTvrtko Ursulin intel_uncore_read(uncore, MAD_DIMM_C0));
3603fa7d235SDaniel Vetter seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n",
3614f5fd91fSTvrtko Ursulin intel_uncore_read(uncore, MAD_DIMM_C1));
3623fa7d235SDaniel Vetter seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n",
3634f5fd91fSTvrtko Ursulin intel_uncore_read(uncore, MAD_DIMM_C2));
3643fa7d235SDaniel Vetter seq_printf(m, "TILECTL = 0x%08x\n",
3654f5fd91fSTvrtko Ursulin intel_uncore_read(uncore, TILECTL));
366651e7d48SLucas De Marchi if (GRAPHICS_VER(dev_priv) >= 8)
3679d3203e1SBen Widawsky seq_printf(m, "GAMTARBMODE = 0x%08x\n",
3684f5fd91fSTvrtko Ursulin intel_uncore_read(uncore, GAMTARBMODE));
3699d3203e1SBen Widawsky else
3703fa7d235SDaniel Vetter seq_printf(m, "ARB_MODE = 0x%08x\n",
3714f5fd91fSTvrtko Ursulin intel_uncore_read(uncore, ARB_MODE));
3723fa7d235SDaniel Vetter seq_printf(m, "DISP_ARB_CTL = 0x%08x\n",
3734f5fd91fSTvrtko Ursulin intel_uncore_read(uncore, DISP_ARB_CTL));
374ea16a3cdSDaniel Vetter }
375656bfa3aSDaniel Vetter
376d858d569SDaniele Ceraolo Spurio intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
377ea16a3cdSDaniel Vetter
378ea16a3cdSDaniel Vetter return 0;
379ea16a3cdSDaniel Vetter }
380ea16a3cdSDaniel Vetter
i915_rps_boost_info(struct seq_file * m,void * data)3811854d5caSChris Wilson static int i915_rps_boost_info(struct seq_file *m, void *data)
3821854d5caSChris Wilson {
38336cdd013SDavid Weinehall struct drm_i915_private *dev_priv = node_to_i915(m->private);
3842cbc876dSMichał Winiarski struct intel_rps *rps = &to_gt(dev_priv)->rps;
385c0a6aa7eSChris Wilson
38601fabda8SLucas De Marchi seq_printf(m, "RPS enabled? %s\n",
38701fabda8SLucas De Marchi str_yes_no(intel_rps_is_enabled(rps)));
38801fabda8SLucas De Marchi seq_printf(m, "RPS active? %s\n",
38901fabda8SLucas De Marchi str_yes_no(intel_rps_is_active(rps)));
39001fabda8SLucas De Marchi seq_printf(m, "GPU busy? %s\n", str_yes_no(to_gt(dev_priv)->awake));
3917b92c1bdSChris Wilson seq_printf(m, "Boosts outstanding? %d\n",
392562d9baeSSagar Arun Kamble atomic_read(&rps->num_waiters));
39360548c55SChris Wilson seq_printf(m, "Interactive? %d\n", READ_ONCE(rps->power.interactive));
394c0a6aa7eSChris Wilson seq_printf(m, "Frequency requested %d, actual %d\n",
3953e7abf81SAndi Shyti intel_gpu_freq(rps, rps->cur_freq),
396e03512edSAndi Shyti intel_rps_read_actual_frequency(rps));
3977466c291SChris Wilson seq_printf(m, " min hard:%d, soft:%d; max soft:%d, hard:%d\n",
3983e7abf81SAndi Shyti intel_gpu_freq(rps, rps->min_freq),
3993e7abf81SAndi Shyti intel_gpu_freq(rps, rps->min_freq_softlimit),
4003e7abf81SAndi Shyti intel_gpu_freq(rps, rps->max_freq_softlimit),
4013e7abf81SAndi Shyti intel_gpu_freq(rps, rps->max_freq));
4027466c291SChris Wilson seq_printf(m, " idle:%d, efficient:%d, boost:%d\n",
4033e7abf81SAndi Shyti intel_gpu_freq(rps, rps->idle_freq),
4043e7abf81SAndi Shyti intel_gpu_freq(rps, rps->efficient_freq),
4053e7abf81SAndi Shyti intel_gpu_freq(rps, rps->boost_freq));
4061d2ac403SDaniel Vetter
4074e5c8a99SChris Wilson seq_printf(m, "Wait boosts: %d\n", READ_ONCE(rps->boosts));
4081854d5caSChris Wilson
40963573eb7SBen Widawsky return 0;
41063573eb7SBen Widawsky }
41163573eb7SBen Widawsky
i915_runtime_pm_status(struct seq_file * m,void * unused)4126455c870SDamien Lespiau static int i915_runtime_pm_status(struct seq_file *m, void *unused)
413371db66aSPaulo Zanoni {
41436cdd013SDavid Weinehall struct drm_i915_private *dev_priv = node_to_i915(m->private);
4158ff5446aSThomas Zimmermann struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
416371db66aSPaulo Zanoni
417a156e64dSChris Wilson if (!HAS_RUNTIME_PM(dev_priv))
418a156e64dSChris Wilson seq_puts(m, "Runtime power management not supported\n");
419371db66aSPaulo Zanoni
42025c896bdSChris Wilson seq_printf(m, "Runtime power status: %s\n",
421e3e8148fSJani Nikula str_enabled_disabled(!dev_priv->display.power.domains.init_wakeref));
42225c896bdSChris Wilson
42301fabda8SLucas De Marchi seq_printf(m, "GPU idle: %s\n", str_yes_no(!to_gt(dev_priv)->awake));
424371db66aSPaulo Zanoni seq_printf(m, "IRQs disabled: %s\n",
42501fabda8SLucas De Marchi str_yes_no(!intel_irqs_enabled(dev_priv)));
4260d804184SChris Wilson #ifdef CONFIG_PM
427a6aaec8bSDamien Lespiau seq_printf(m, "Usage count: %d\n",
42836cdd013SDavid Weinehall atomic_read(&dev_priv->drm.dev->power.usage_count));
4290d804184SChris Wilson #else
4300d804184SChris Wilson seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n");
4310d804184SChris Wilson #endif
432a156e64dSChris Wilson seq_printf(m, "PCI device power state: %s [%d]\n",
43352a05c30SDavid Weinehall pci_power_name(pdev->current_state),
43452a05c30SDavid Weinehall pdev->current_state);
435371db66aSPaulo Zanoni
436bd780f37SChris Wilson if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)) {
437bd780f37SChris Wilson struct drm_printer p = drm_seq_file_printer(m);
438bd780f37SChris Wilson
43969c66355SDaniele Ceraolo Spurio print_intel_runtime_pm_wakeref(&dev_priv->runtime_pm, &p);
440bd780f37SChris Wilson }
441bd780f37SChris Wilson
442ec013e7fSJesse Barnes return 0;
443ec013e7fSJesse Barnes }
444ec013e7fSJesse Barnes
i915_engine_info(struct seq_file * m,void * unused)4451b36595fSChris Wilson static int i915_engine_info(struct seq_file *m, void *unused)
4461b36595fSChris Wilson {
4470986317aSChris Wilson struct drm_i915_private *i915 = node_to_i915(m->private);
4481b36595fSChris Wilson struct intel_engine_cs *engine;
449a037121cSChris Wilson intel_wakeref_t wakeref;
450f636edb2SChris Wilson struct drm_printer p;
4511b36595fSChris Wilson
4520986317aSChris Wilson wakeref = intel_runtime_pm_get(&i915->runtime_pm);
4539c870d03SChris Wilson
4548c3b1ba0SChris Wilson seq_printf(m, "GT awake? %s [%d], %llums\n",
45501fabda8SLucas De Marchi str_yes_no(to_gt(i915)->awake),
4562cbc876dSMichał Winiarski atomic_read(&to_gt(i915)->wakeref.count),
4572cbc876dSMichał Winiarski ktime_to_ms(intel_gt_get_awake_time(to_gt(i915))));
458f170523aSChris Wilson seq_printf(m, "CS timestamp frequency: %u Hz, %d ns\n",
4592cbc876dSMichał Winiarski to_gt(i915)->clock_frequency,
4602cbc876dSMichał Winiarski to_gt(i915)->clock_period_ns);
461f73b5674SChris Wilson
462f636edb2SChris Wilson p = drm_seq_file_printer(m);
4630986317aSChris Wilson for_each_uabi_engine(engine, i915)
4640db18b17SChris Wilson intel_engine_dump(engine, &p, "%s\n", engine->name);
4651b36595fSChris Wilson
4662cbc876dSMichał Winiarski intel_gt_show_timelines(to_gt(i915), &p, i915_request_show_with_schedule);
4670986317aSChris Wilson
4680986317aSChris Wilson intel_runtime_pm_put(&i915->runtime_pm, wakeref);
4699c870d03SChris Wilson
4701b36595fSChris Wilson return 0;
4711b36595fSChris Wilson }
4721b36595fSChris Wilson
i915_wa_registers(struct seq_file * m,void * unused)4731ed1ef9dSDamien Lespiau static int i915_wa_registers(struct seq_file *m, void *unused)
474888b5995SArun Siluvery {
475452420d2STvrtko Ursulin struct drm_i915_private *i915 = node_to_i915(m->private);
4764a54da35SChris Wilson struct intel_engine_cs *engine;
477888b5995SArun Siluvery
478750e76b4SChris Wilson for_each_uabi_engine(engine, i915) {
4794a54da35SChris Wilson const struct i915_wa_list *wal = &engine->ctx_wa_list;
4804a54da35SChris Wilson const struct i915_wa *wa;
4814a54da35SChris Wilson unsigned int count;
4824a54da35SChris Wilson
4834a54da35SChris Wilson count = wal->count;
4844a54da35SChris Wilson if (!count)
4854a54da35SChris Wilson continue;
4864a54da35SChris Wilson
4874a54da35SChris Wilson seq_printf(m, "%s: Workarounds applied: %u\n",
4884a54da35SChris Wilson engine->name, count);
4894a54da35SChris Wilson
4904a54da35SChris Wilson for (wa = wal->list; count--; wa++)
491548764bbSChris Wilson seq_printf(m, "0x%X: 0x%08X, mask: 0x%08X\n",
4924a54da35SChris Wilson i915_mmio_reg_offset(wa->reg),
493eeec73f8SChris Wilson wa->set, wa->clr);
4944a54da35SChris Wilson
4954a54da35SChris Wilson seq_printf(m, "\n");
4964a54da35SChris Wilson }
497888b5995SArun Siluvery
498888b5995SArun Siluvery return 0;
499888b5995SArun Siluvery }
500888b5995SArun Siluvery
i915_wedged_get(void * data,u64 * val)50182a149a6SAndi Shyti static int i915_wedged_get(void *data, u64 *val)
502f3cd474bSChris Wilson {
503598b6b5aSChris Wilson struct drm_i915_private *i915 = data;
50480ac788aSAndi Shyti struct intel_gt *gt;
50580ac788aSAndi Shyti unsigned int i;
506d46c0517SImre Deak
50780ac788aSAndi Shyti *val = 0;
50880ac788aSAndi Shyti
50980ac788aSAndi Shyti for_each_gt(gt, i915, i) {
51080ac788aSAndi Shyti int ret;
51180ac788aSAndi Shyti
51280ac788aSAndi Shyti ret = intel_gt_debugfs_reset_show(gt, val);
51380ac788aSAndi Shyti if (ret)
51480ac788aSAndi Shyti return ret;
51580ac788aSAndi Shyti
51680ac788aSAndi Shyti /* at least one tile should be wedged */
51780ac788aSAndi Shyti if (*val)
51880ac788aSAndi Shyti break;
51980ac788aSAndi Shyti }
52080ac788aSAndi Shyti
52180ac788aSAndi Shyti return 0;
52282a149a6SAndi Shyti }
523b8d24a06SMika Kuoppala
i915_wedged_set(void * data,u64 val)52482a149a6SAndi Shyti static int i915_wedged_set(void *data, u64 val)
52582a149a6SAndi Shyti {
52682a149a6SAndi Shyti struct drm_i915_private *i915 = data;
52780ac788aSAndi Shyti struct intel_gt *gt;
52880ac788aSAndi Shyti unsigned int i;
52980ac788aSAndi Shyti
53080ac788aSAndi Shyti for_each_gt(gt, i915, i)
53180ac788aSAndi Shyti intel_gt_debugfs_reset_store(gt, val);
53282a149a6SAndi Shyti
5337d14db8bSAndi Shyti return 0;
534f3cd474bSChris Wilson }
535f3cd474bSChris Wilson
536647416f9SKees Cook DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops,
537647416f9SKees Cook i915_wedged_get, i915_wedged_set,
5383a3b4f98SMika Kuoppala "%llu\n");
539f3cd474bSChris Wilson
540daed3e44SLionel Landwerlin static int
i915_perf_noa_delay_set(void * data,u64 val)541daed3e44SLionel Landwerlin i915_perf_noa_delay_set(void *data, u64 val)
542daed3e44SLionel Landwerlin {
543daed3e44SLionel Landwerlin struct drm_i915_private *i915 = data;
544daed3e44SLionel Landwerlin
545daed3e44SLionel Landwerlin /*
546daed3e44SLionel Landwerlin * This would lead to infinite waits as we're doing timestamp
547daed3e44SLionel Landwerlin * difference on the CS with only 32bits.
548daed3e44SLionel Landwerlin */
5492cbc876dSMichał Winiarski if (intel_gt_ns_to_clock_interval(to_gt(i915), val) > U32_MAX)
550daed3e44SLionel Landwerlin return -EINVAL;
551daed3e44SLionel Landwerlin
552daed3e44SLionel Landwerlin atomic64_set(&i915->perf.noa_programming_delay, val);
553daed3e44SLionel Landwerlin return 0;
554daed3e44SLionel Landwerlin }
555daed3e44SLionel Landwerlin
556daed3e44SLionel Landwerlin static int
i915_perf_noa_delay_get(void * data,u64 * val)557daed3e44SLionel Landwerlin i915_perf_noa_delay_get(void *data, u64 *val)
558daed3e44SLionel Landwerlin {
559daed3e44SLionel Landwerlin struct drm_i915_private *i915 = data;
560daed3e44SLionel Landwerlin
561daed3e44SLionel Landwerlin *val = atomic64_read(&i915->perf.noa_programming_delay);
562daed3e44SLionel Landwerlin return 0;
563daed3e44SLionel Landwerlin }
564daed3e44SLionel Landwerlin
565daed3e44SLionel Landwerlin DEFINE_SIMPLE_ATTRIBUTE(i915_perf_noa_delay_fops,
566daed3e44SLionel Landwerlin i915_perf_noa_delay_get,
567daed3e44SLionel Landwerlin i915_perf_noa_delay_set,
568daed3e44SLionel Landwerlin "%llu\n");
569daed3e44SLionel Landwerlin
570b4a0b32dSChris Wilson #define DROP_UNBOUND BIT(0)
571b4a0b32dSChris Wilson #define DROP_BOUND BIT(1)
572b4a0b32dSChris Wilson #define DROP_RETIRE BIT(2)
573b4a0b32dSChris Wilson #define DROP_ACTIVE BIT(3)
574b4a0b32dSChris Wilson #define DROP_FREED BIT(4)
575b4a0b32dSChris Wilson #define DROP_SHRINK_ALL BIT(5)
576b4a0b32dSChris Wilson #define DROP_IDLE BIT(6)
5776b048706SChris Wilson #define DROP_RESET_ACTIVE BIT(7)
5786b048706SChris Wilson #define DROP_RESET_SEQNO BIT(8)
57954895010SChris Wilson #define DROP_RCU BIT(9)
580dd624afdSChris Wilson #define DROP_ALL (DROP_UNBOUND | \
581dd624afdSChris Wilson DROP_BOUND | \
582dd624afdSChris Wilson DROP_RETIRE | \
583fbbd37b3SChris Wilson DROP_ACTIVE | \
5848eadc19bSChris Wilson DROP_FREED | \
585b4a0b32dSChris Wilson DROP_SHRINK_ALL |\
5866b048706SChris Wilson DROP_IDLE | \
5876b048706SChris Wilson DROP_RESET_ACTIVE | \
58854895010SChris Wilson DROP_RESET_SEQNO | \
58954895010SChris Wilson DROP_RCU)
590647416f9SKees Cook static int
i915_drop_caches_get(void * data,u64 * val)591647416f9SKees Cook i915_drop_caches_get(void *data, u64 *val)
592dd624afdSChris Wilson {
593647416f9SKees Cook *val = DROP_ALL;
594dd624afdSChris Wilson
595647416f9SKees Cook return 0;
596dd624afdSChris Wilson }
5976c13c825SJani Nikula
598647416f9SKees Cook static int
gt_drop_caches(struct intel_gt * gt,u64 val)5998726a2a4STvrtko Ursulin gt_drop_caches(struct intel_gt *gt, u64 val)
600dd624afdSChris Wilson {
6017e805762SChris Wilson int ret;
602dd624afdSChris Wilson
603ad4062daSChris Wilson if (val & DROP_RESET_ACTIVE &&
604fdbc5aebSRodrigo Vivi wait_for(intel_engines_are_idle(gt), 200))
60566101975SChris Wilson intel_gt_set_wedged(gt);
6066b048706SChris Wilson
6076b048706SChris Wilson if (val & DROP_RETIRE)
60866101975SChris Wilson intel_gt_retire_requests(gt);
6096b048706SChris Wilson
6107e805762SChris Wilson if (val & (DROP_IDLE | DROP_ACTIVE)) {
61166101975SChris Wilson ret = intel_gt_wait_for_idle(gt, MAX_SCHEDULE_TIMEOUT);
6127e805762SChris Wilson if (ret)
6137e805762SChris Wilson return ret;
6147e805762SChris Wilson }
615c7302f20SChris Wilson
6167e805762SChris Wilson if (val & DROP_IDLE) {
61766101975SChris Wilson ret = intel_gt_pm_wait_for_idle(gt);
6187e805762SChris Wilson if (ret)
6197e805762SChris Wilson return ret;
6206b048706SChris Wilson }
6216b048706SChris Wilson
62266101975SChris Wilson if (val & DROP_RESET_ACTIVE && intel_gt_terminally_wedged(gt))
62366101975SChris Wilson intel_gt_handle_error(gt, ALL_ENGINES, 0, NULL);
62400c26cf9SChris Wilson
62516e87459SChris Wilson if (val & DROP_FREED)
62616e87459SChris Wilson intel_gt_flush_buffer_pool(gt);
62716e87459SChris Wilson
6288726a2a4STvrtko Ursulin return 0;
6298726a2a4STvrtko Ursulin }
6308726a2a4STvrtko Ursulin
6318726a2a4STvrtko Ursulin static int
i915_drop_caches_set(void * data,u64 val)6328726a2a4STvrtko Ursulin i915_drop_caches_set(void *data, u64 val)
6338726a2a4STvrtko Ursulin {
6348726a2a4STvrtko Ursulin struct drm_i915_private *i915 = data;
635c795d2f4STvrtko Ursulin struct intel_gt *gt;
6361b9e8b1fSMatthew Auld unsigned int flags;
637c795d2f4STvrtko Ursulin unsigned int i;
6388726a2a4STvrtko Ursulin int ret;
6398726a2a4STvrtko Ursulin
640a10234fdSTvrtko Ursulin drm_dbg(&i915->drm, "Dropping caches: 0x%08llx [0x%08llx]\n",
6418726a2a4STvrtko Ursulin val, val & DROP_ALL);
6428726a2a4STvrtko Ursulin
643c795d2f4STvrtko Ursulin for_each_gt(gt, i915, i) {
644c795d2f4STvrtko Ursulin ret = gt_drop_caches(gt, val);
6458726a2a4STvrtko Ursulin if (ret)
6468726a2a4STvrtko Ursulin return ret;
647c795d2f4STvrtko Ursulin }
6488726a2a4STvrtko Ursulin
649d92a8cfcSPeter Zijlstra fs_reclaim_acquire(GFP_KERNEL);
6501b9e8b1fSMatthew Auld flags = memalloc_noreclaim_save();
65121ab4e74SChris Wilson if (val & DROP_BOUND)
652cf41a8f1SMaarten Lankhorst i915_gem_shrink(NULL, i915, LONG_MAX, NULL, I915_SHRINK_BOUND);
6534ad72b7fSChris Wilson
65421ab4e74SChris Wilson if (val & DROP_UNBOUND)
655cf41a8f1SMaarten Lankhorst i915_gem_shrink(NULL, i915, LONG_MAX, NULL, I915_SHRINK_UNBOUND);
656dd624afdSChris Wilson
6578eadc19bSChris Wilson if (val & DROP_SHRINK_ALL)
6586b048706SChris Wilson i915_gem_shrink_all(i915);
6591b9e8b1fSMatthew Auld memalloc_noreclaim_restore(flags);
660d92a8cfcSPeter Zijlstra fs_reclaim_release(GFP_KERNEL);
6618eadc19bSChris Wilson
66254895010SChris Wilson if (val & DROP_RCU)
66354895010SChris Wilson rcu_barrier();
66454895010SChris Wilson
665c9c70471SChris Wilson if (val & DROP_FREED)
6666b048706SChris Wilson i915_gem_drain_freed_objects(i915);
667fbbd37b3SChris Wilson
6686cffeb83SChris Wilson return 0;
669dd624afdSChris Wilson }
670dd624afdSChris Wilson
671647416f9SKees Cook DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops,
672647416f9SKees Cook i915_drop_caches_get, i915_drop_caches_set,
673647416f9SKees Cook "0x%08llx\n");
674dd624afdSChris Wilson
i915_sseu_status(struct seq_file * m,void * unused)6753873218fSJeff McGee static int i915_sseu_status(struct seq_file *m, void *unused)
6763873218fSJeff McGee {
6775df79ff1SDaniele Ceraolo Spurio struct drm_i915_private *i915 = node_to_i915(m->private);
6782cbc876dSMichał Winiarski struct intel_gt *gt = to_gt(i915);
6793873218fSJeff McGee
680a00eda7dSDaniele Ceraolo Spurio return intel_sseu_status(m, gt);
6813873218fSJeff McGee }
6823873218fSJeff McGee
i915_forcewake_open(struct inode * inode,struct file * file)6836d794d42SBen Widawsky static int i915_forcewake_open(struct inode *inode, struct file *file)
6846d794d42SBen Widawsky {
685d7a133d8SChris Wilson struct drm_i915_private *i915 = inode->i_private;
68680ac788aSAndi Shyti struct intel_gt *gt;
68780ac788aSAndi Shyti unsigned int i;
68880ac788aSAndi Shyti
68980ac788aSAndi Shyti for_each_gt(gt, i915, i)
69080ac788aSAndi Shyti intel_gt_pm_debugfs_forcewake_user_open(gt);
6916d794d42SBen Widawsky
6927d14db8bSAndi Shyti return 0;
6936d794d42SBen Widawsky }
6946d794d42SBen Widawsky
i915_forcewake_release(struct inode * inode,struct file * file)695c43b5634SBen Widawsky static int i915_forcewake_release(struct inode *inode, struct file *file)
6966d794d42SBen Widawsky {
697d7a133d8SChris Wilson struct drm_i915_private *i915 = inode->i_private;
69880ac788aSAndi Shyti struct intel_gt *gt;
69980ac788aSAndi Shyti unsigned int i;
70080ac788aSAndi Shyti
70180ac788aSAndi Shyti for_each_gt(gt, i915, i)
70280ac788aSAndi Shyti intel_gt_pm_debugfs_forcewake_user_release(gt);
7036d794d42SBen Widawsky
7047d14db8bSAndi Shyti return 0;
7056d794d42SBen Widawsky }
7066d794d42SBen Widawsky
7076d794d42SBen Widawsky static const struct file_operations i915_forcewake_fops = {
7086d794d42SBen Widawsky .owner = THIS_MODULE,
7096d794d42SBen Widawsky .open = i915_forcewake_open,
7106d794d42SBen Widawsky .release = i915_forcewake_release,
7116d794d42SBen Widawsky };
7126d794d42SBen Widawsky
71306c5bf8cSLespiau, Damien static const struct drm_info_list i915_debugfs_list[] = {
714311bd68eSChris Wilson {"i915_capabilities", i915_capabilities, 0},
71573aa808fSChris Wilson {"i915_gem_objects", i915_gem_object_info, 0},
716adb4bd12SDeepak S {"i915_frequency_info", i915_frequency_info, 0},
717ea16a3cdSDaniel Vetter {"i915_swizzle_info", i915_swizzle_info, 0},
7186455c870SDamien Lespiau {"i915_runtime_pm_status", i915_runtime_pm_status, 0},
7191b36595fSChris Wilson {"i915_engine_info", i915_engine_info, 0},
7201ed1ef9dSDamien Lespiau {"i915_wa_registers", i915_wa_registers, 0},
7213873218fSJeff McGee {"i915_sseu_status", i915_sseu_status, 0},
7221854d5caSChris Wilson {"i915_rps_boost_info", i915_rps_boost_info, 0},
72327c202adSBen Gamari };
72427c202adSBen Gamari
72506c5bf8cSLespiau, Damien static const struct i915_debugfs_files {
72634b9674cSDaniel Vetter const char *name;
72734b9674cSDaniel Vetter const struct file_operations *fops;
72834b9674cSDaniel Vetter } i915_debugfs_files[] = {
729daed3e44SLionel Landwerlin {"i915_perf_noa_delay", &i915_perf_noa_delay_fops},
73034b9674cSDaniel Vetter {"i915_wedged", &i915_wedged_fops},
73134b9674cSDaniel Vetter {"i915_gem_drop_caches", &i915_drop_caches_fops},
73234b9674cSDaniel Vetter };
73334b9674cSDaniel Vetter
i915_debugfs_register(struct drm_i915_private * dev_priv)734f06b2052SWambui Karuga void i915_debugfs_register(struct drm_i915_private *dev_priv)
73527c202adSBen Gamari {
73691c8a326SChris Wilson struct drm_minor *minor = dev_priv->drm.primary;
7376cc42152SMaarten Lankhorst int i;
738f3cd474bSChris Wilson
739c43c5a88SJani Nikula i915_debugfs_params(dev_priv);
740c43c5a88SJani Nikula
7410780f3b6SGreg Kroah-Hartman debugfs_create_file("i915_forcewake_user", S_IRUSR, minor->debugfs_root,
7420780f3b6SGreg Kroah-Hartman to_i915(minor->dev), &i915_forcewake_fops);
74334b9674cSDaniel Vetter for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
7440780f3b6SGreg Kroah-Hartman debugfs_create_file(i915_debugfs_files[i].name,
745b05eeb0fSNoralf Trønnes S_IRUGO | S_IWUSR,
746b05eeb0fSNoralf Trønnes minor->debugfs_root,
747b05eeb0fSNoralf Trønnes to_i915(minor->dev),
74834b9674cSDaniel Vetter i915_debugfs_files[i].fops);
74934b9674cSDaniel Vetter }
75040633219SMika Kuoppala
751f06b2052SWambui Karuga drm_debugfs_create_files(i915_debugfs_list,
752fdbc5aebSRodrigo Vivi ARRAY_SIZE(i915_debugfs_list),
75327c202adSBen Gamari minor->debugfs_root, minor);
7544fca5198SJani Nikula
7554fca5198SJani Nikula i915_gpu_error_debugfs_register(dev_priv);
75627c202adSBen Gamari }
757