brintos

brintos / linux-shallow public Read only

0
0
Text · 8.6 KiB · 8f95d3a Raw
338 lines · c
1// SPDX-License-Identifier: MIT2/*3 * Copyright © 2022 Intel Corporation4 */5 6#include "xe_gt_debugfs.h"7 8#include <linux/debugfs.h>9 10#include <drm/drm_debugfs.h>11#include <drm/drm_managed.h>12 13#include "xe_device.h"14#include "xe_force_wake.h"15#include "xe_ggtt.h"16#include "xe_gt.h"17#include "xe_gt_mcr.h"18#include "xe_gt_sriov_pf_debugfs.h"19#include "xe_gt_sriov_vf_debugfs.h"20#include "xe_gt_stats.h"21#include "xe_gt_topology.h"22#include "xe_guc_hwconfig.h"23#include "xe_hw_engine.h"24#include "xe_lrc.h"25#include "xe_macros.h"26#include "xe_mocs.h"27#include "xe_pat.h"28#include "xe_pm.h"29#include "xe_reg_sr.h"30#include "xe_reg_whitelist.h"31#include "xe_sriov.h"32#include "xe_uc_debugfs.h"33#include "xe_wa.h"34 35/**36 * xe_gt_debugfs_simple_show - A show callback for struct drm_info_list37 * @m: the &seq_file38 * @data: data used by the drm debugfs helpers39 *40 * This callback can be used in struct drm_info_list to describe debugfs41 * files that are &xe_gt specific.42 *43 * It is assumed that those debugfs files will be created on directory entry44 * which struct dentry d_inode->i_private points to &xe_gt.45 *46 * This function assumes that &m->private will be set to the &struct47 * drm_info_node corresponding to the instance of the info on a given &struct48 * drm_minor (see struct drm_info_list.show for details).49 *50 * This function also assumes that struct drm_info_list.data will point to the51 * function code that will actually print a file content::52 *53 *   int (*print)(struct xe_gt *, struct drm_printer *)54 *55 * Example::56 *57 *    int foo(struct xe_gt *gt, struct drm_printer *p)58 *    {59 *        drm_printf(p, "GT%u\n", gt->info.id);60 *        return 0;61 *    }62 *63 *    static const struct drm_info_list bar[] = {64 *        { name = "foo", .show = xe_gt_debugfs_simple_show, .data = foo },65 *    };66 *67 *    dir = debugfs_create_dir("gt", parent);68 *    dir->d_inode->i_private = gt;69 *    drm_debugfs_create_files(bar, ARRAY_SIZE(bar), dir, minor);70 *71 * Return: 0 on success or a negative error code on failure.72 */73int xe_gt_debugfs_simple_show(struct seq_file *m, void *data)74{75	struct drm_printer p = drm_seq_file_printer(m);76	struct drm_info_node *node = m->private;77	struct dentry *parent = node->dent->d_parent;78	struct xe_gt *gt = parent->d_inode->i_private;79	int (*print)(struct xe_gt *, struct drm_printer *) = node->info_ent->data;80 81	if (WARN_ON(!print))82		return -EINVAL;83 84	return print(gt, &p);85}86 87static int hw_engines(struct xe_gt *gt, struct drm_printer *p)88{89	struct xe_device *xe = gt_to_xe(gt);90	struct xe_hw_engine *hwe;91	enum xe_hw_engine_id id;92	int err;93 94	xe_pm_runtime_get(xe);95	err = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);96	if (err) {97		xe_pm_runtime_put(xe);98		return err;99	}100 101	for_each_hw_engine(hwe, gt, id)102		xe_hw_engine_print(hwe, p);103 104	err = xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL);105	xe_pm_runtime_put(xe);106	if (err)107		return err;108 109	return 0;110}111 112static int force_reset(struct xe_gt *gt, struct drm_printer *p)113{114	xe_pm_runtime_get(gt_to_xe(gt));115	xe_gt_reset_async(gt);116	xe_pm_runtime_put(gt_to_xe(gt));117 118	return 0;119}120 121static int force_reset_sync(struct xe_gt *gt, struct drm_printer *p)122{123	xe_pm_runtime_get(gt_to_xe(gt));124	xe_gt_reset_async(gt);125	xe_pm_runtime_put(gt_to_xe(gt));126 127	flush_work(&gt->reset.worker);128 129	return 0;130}131 132static int sa_info(struct xe_gt *gt, struct drm_printer *p)133{134	struct xe_tile *tile = gt_to_tile(gt);135 136	xe_pm_runtime_get(gt_to_xe(gt));137	drm_suballoc_dump_debug_info(&tile->mem.kernel_bb_pool->base, p,138				     tile->mem.kernel_bb_pool->gpu_addr);139	xe_pm_runtime_put(gt_to_xe(gt));140 141	return 0;142}143 144static int topology(struct xe_gt *gt, struct drm_printer *p)145{146	xe_pm_runtime_get(gt_to_xe(gt));147	xe_gt_topology_dump(gt, p);148	xe_pm_runtime_put(gt_to_xe(gt));149 150	return 0;151}152 153static int steering(struct xe_gt *gt, struct drm_printer *p)154{155	xe_pm_runtime_get(gt_to_xe(gt));156	xe_gt_mcr_steering_dump(gt, p);157	xe_pm_runtime_put(gt_to_xe(gt));158 159	return 0;160}161 162static int ggtt(struct xe_gt *gt, struct drm_printer *p)163{164	int ret;165 166	xe_pm_runtime_get(gt_to_xe(gt));167	ret = xe_ggtt_dump(gt_to_tile(gt)->mem.ggtt, p);168	xe_pm_runtime_put(gt_to_xe(gt));169 170	return ret;171}172 173static int register_save_restore(struct xe_gt *gt, struct drm_printer *p)174{175	struct xe_hw_engine *hwe;176	enum xe_hw_engine_id id;177 178	xe_pm_runtime_get(gt_to_xe(gt));179 180	xe_reg_sr_dump(&gt->reg_sr, p);181	drm_printf(p, "\n");182 183	drm_printf(p, "Engine\n");184	for_each_hw_engine(hwe, gt, id)185		xe_reg_sr_dump(&hwe->reg_sr, p);186	drm_printf(p, "\n");187 188	drm_printf(p, "LRC\n");189	for_each_hw_engine(hwe, gt, id)190		xe_reg_sr_dump(&hwe->reg_lrc, p);191	drm_printf(p, "\n");192 193	drm_printf(p, "Whitelist\n");194	for_each_hw_engine(hwe, gt, id)195		xe_reg_whitelist_dump(&hwe->reg_whitelist, p);196 197	xe_pm_runtime_put(gt_to_xe(gt));198 199	return 0;200}201 202static int workarounds(struct xe_gt *gt, struct drm_printer *p)203{204	xe_pm_runtime_get(gt_to_xe(gt));205	xe_wa_dump(gt, p);206	xe_pm_runtime_put(gt_to_xe(gt));207 208	return 0;209}210 211static int pat(struct xe_gt *gt, struct drm_printer *p)212{213	xe_pm_runtime_get(gt_to_xe(gt));214	xe_pat_dump(gt, p);215	xe_pm_runtime_put(gt_to_xe(gt));216 217	return 0;218}219 220static int mocs(struct xe_gt *gt, struct drm_printer *p)221{222	xe_pm_runtime_get(gt_to_xe(gt));223	xe_mocs_dump(gt, p);224	xe_pm_runtime_put(gt_to_xe(gt));225 226	return 0;227}228 229static int rcs_default_lrc(struct xe_gt *gt, struct drm_printer *p)230{231	xe_pm_runtime_get(gt_to_xe(gt));232	xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_RENDER);233	xe_pm_runtime_put(gt_to_xe(gt));234 235	return 0;236}237 238static int ccs_default_lrc(struct xe_gt *gt, struct drm_printer *p)239{240	xe_pm_runtime_get(gt_to_xe(gt));241	xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_COMPUTE);242	xe_pm_runtime_put(gt_to_xe(gt));243 244	return 0;245}246 247static int bcs_default_lrc(struct xe_gt *gt, struct drm_printer *p)248{249	xe_pm_runtime_get(gt_to_xe(gt));250	xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_COPY);251	xe_pm_runtime_put(gt_to_xe(gt));252 253	return 0;254}255 256static int vcs_default_lrc(struct xe_gt *gt, struct drm_printer *p)257{258	xe_pm_runtime_get(gt_to_xe(gt));259	xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_VIDEO_DECODE);260	xe_pm_runtime_put(gt_to_xe(gt));261 262	return 0;263}264 265static int vecs_default_lrc(struct xe_gt *gt, struct drm_printer *p)266{267	xe_pm_runtime_get(gt_to_xe(gt));268	xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_VIDEO_ENHANCE);269	xe_pm_runtime_put(gt_to_xe(gt));270 271	return 0;272}273 274static int hwconfig(struct xe_gt *gt, struct drm_printer *p)275{276	xe_pm_runtime_get(gt_to_xe(gt));277	xe_guc_hwconfig_dump(&gt->uc.guc, p);278	xe_pm_runtime_put(gt_to_xe(gt));279 280	return 0;281}282 283static const struct drm_info_list debugfs_list[] = {284	{"hw_engines", .show = xe_gt_debugfs_simple_show, .data = hw_engines},285	{"force_reset", .show = xe_gt_debugfs_simple_show, .data = force_reset},286	{"force_reset_sync", .show = xe_gt_debugfs_simple_show, .data = force_reset_sync},287	{"sa_info", .show = xe_gt_debugfs_simple_show, .data = sa_info},288	{"topology", .show = xe_gt_debugfs_simple_show, .data = topology},289	{"steering", .show = xe_gt_debugfs_simple_show, .data = steering},290	{"ggtt", .show = xe_gt_debugfs_simple_show, .data = ggtt},291	{"register-save-restore", .show = xe_gt_debugfs_simple_show, .data = register_save_restore},292	{"workarounds", .show = xe_gt_debugfs_simple_show, .data = workarounds},293	{"pat", .show = xe_gt_debugfs_simple_show, .data = pat},294	{"mocs", .show = xe_gt_debugfs_simple_show, .data = mocs},295	{"default_lrc_rcs", .show = xe_gt_debugfs_simple_show, .data = rcs_default_lrc},296	{"default_lrc_ccs", .show = xe_gt_debugfs_simple_show, .data = ccs_default_lrc},297	{"default_lrc_bcs", .show = xe_gt_debugfs_simple_show, .data = bcs_default_lrc},298	{"default_lrc_vcs", .show = xe_gt_debugfs_simple_show, .data = vcs_default_lrc},299	{"default_lrc_vecs", .show = xe_gt_debugfs_simple_show, .data = vecs_default_lrc},300	{"stats", .show = xe_gt_debugfs_simple_show, .data = xe_gt_stats_print_info},301	{"hwconfig", .show = xe_gt_debugfs_simple_show, .data = hwconfig},302};303 304void xe_gt_debugfs_register(struct xe_gt *gt)305{306	struct xe_device *xe = gt_to_xe(gt);307	struct drm_minor *minor = gt_to_xe(gt)->drm.primary;308	struct dentry *root;309	char name[8];310 311	xe_gt_assert(gt, minor->debugfs_root);312 313	snprintf(name, sizeof(name), "gt%d", gt->info.id);314	root = debugfs_create_dir(name, minor->debugfs_root);315	if (IS_ERR(root)) {316		drm_warn(&xe->drm, "Create GT directory failed");317		return;318	}319 320	/*321	 * Store the xe_gt pointer as private data of the gt/ directory node322	 * so other GT specific attributes under that directory may refer to323	 * it by looking at its parent node private data.324	 */325	root->d_inode->i_private = gt;326 327	drm_debugfs_create_files(debugfs_list,328				 ARRAY_SIZE(debugfs_list),329				 root, minor);330 331	xe_uc_debugfs_register(&gt->uc, root);332 333	if (IS_SRIOV_PF(xe))334		xe_gt_sriov_pf_debugfs_register(gt, root);335	else if (IS_SRIOV_VF(xe))336		xe_gt_sriov_vf_debugfs_register(gt, root);337}338