xref: /linux/drivers/gpu/drm/i915/gt/uc/intel_uc_debugfs.c (revision 0be3ff0c)
1 // SPDX-License-Identifier: MIT
2 /*
3  * Copyright © 2020 Intel Corporation
4  */
5 
6 #include <linux/debugfs.h>
7 #include <drm/drm_print.h>
8 
9 #include "gt/intel_gt_debugfs.h"
10 #include "intel_guc_debugfs.h"
11 #include "intel_huc_debugfs.h"
12 #include "intel_uc.h"
13 #include "intel_uc_debugfs.h"
14 
15 static int uc_usage_show(struct seq_file *m, void *data)
16 {
17 	struct intel_uc *uc = m->private;
18 	struct drm_printer p = drm_seq_file_printer(m);
19 
20 	drm_printf(&p, "[guc] supported:%s wanted:%s used:%s\n",
21 		   yesno(intel_uc_supports_guc(uc)),
22 		   yesno(intel_uc_wants_guc(uc)),
23 		   yesno(intel_uc_uses_guc(uc)));
24 	drm_printf(&p, "[huc] supported:%s wanted:%s used:%s\n",
25 		   yesno(intel_uc_supports_huc(uc)),
26 		   yesno(intel_uc_wants_huc(uc)),
27 		   yesno(intel_uc_uses_huc(uc)));
28 	drm_printf(&p, "[submission] supported:%s wanted:%s used:%s\n",
29 		   yesno(intel_uc_supports_guc_submission(uc)),
30 		   yesno(intel_uc_wants_guc_submission(uc)),
31 		   yesno(intel_uc_uses_guc_submission(uc)));
32 
33 	return 0;
34 }
35 DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(uc_usage);
36 
37 void intel_uc_debugfs_register(struct intel_uc *uc, struct dentry *gt_root)
38 {
39 	static const struct intel_gt_debugfs_file files[] = {
40 		{ "usage", &uc_usage_fops, NULL },
41 	};
42 	struct dentry *root;
43 
44 	if (!gt_root)
45 		return;
46 
47 	/* GuC and HuC go always in pair, no need to check both */
48 	if (!intel_uc_supports_guc(uc))
49 		return;
50 
51 	root = debugfs_create_dir("uc", gt_root);
52 	if (IS_ERR(root))
53 		return;
54 
55 	intel_gt_debugfs_register_files(root, files, ARRAY_SIZE(files), uc);
56 
57 	intel_guc_debugfs_register(&uc->guc, root);
58 	intel_huc_debugfs_register(&uc->huc, root);
59 }
60