1 // SPDX-License-Identifier: MIT
2 /*
3  * Copyright © 2020 Intel Corporation
4  */
5 
6 #include <drm/drm_print.h>
7 
8 #include "gt/intel_gt_debugfs.h"
9 #include "gt/uc/intel_guc_ads.h"
10 #include "gt/uc/intel_guc_ct.h"
11 #include "gt/uc/intel_guc_slpc.h"
12 #include "gt/uc/intel_guc_submission.h"
13 #include "intel_guc.h"
14 #include "intel_guc_debugfs.h"
15 #include "intel_guc_log_debugfs.h"
16 
guc_info_show(struct seq_file * m,void * data)17 static int guc_info_show(struct seq_file *m, void *data)
18 {
19 	struct intel_guc *guc = m->private;
20 	struct drm_printer p = drm_seq_file_printer(m);
21 
22 	if (!intel_guc_is_supported(guc))
23 		return -ENODEV;
24 
25 	intel_guc_load_status(guc, &p);
26 	drm_puts(&p, "\n");
27 	intel_guc_log_info(&guc->log, &p);
28 
29 	if (!intel_guc_submission_is_used(guc))
30 		return 0;
31 
32 	intel_guc_ct_print_info(&guc->ct, &p);
33 	intel_guc_submission_print_info(guc, &p);
34 	intel_guc_ads_print_policy_info(guc, &p);
35 
36 	return 0;
37 }
38 DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(guc_info);
39 
guc_registered_contexts_show(struct seq_file * m,void * data)40 static int guc_registered_contexts_show(struct seq_file *m, void *data)
41 {
42 	struct intel_guc *guc = m->private;
43 	struct drm_printer p = drm_seq_file_printer(m);
44 
45 	if (!intel_guc_submission_is_used(guc))
46 		return -ENODEV;
47 
48 	intel_guc_submission_print_context_info(guc, &p);
49 
50 	return 0;
51 }
52 DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(guc_registered_contexts);
53 
guc_slpc_info_show(struct seq_file * m,void * unused)54 static int guc_slpc_info_show(struct seq_file *m, void *unused)
55 {
56 	struct intel_guc *guc = m->private;
57 	struct intel_guc_slpc *slpc = &guc->slpc;
58 	struct drm_printer p = drm_seq_file_printer(m);
59 
60 	if (!intel_guc_slpc_is_used(guc))
61 		return -ENODEV;
62 
63 	return intel_guc_slpc_print_info(slpc, &p);
64 }
65 DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(guc_slpc_info);
66 
intel_eval_slpc_support(void * data)67 static bool intel_eval_slpc_support(void *data)
68 {
69 	struct intel_guc *guc = (struct intel_guc *)data;
70 
71 	return intel_guc_slpc_is_used(guc);
72 }
73 
intel_guc_debugfs_register(struct intel_guc * guc,struct dentry * root)74 void intel_guc_debugfs_register(struct intel_guc *guc, struct dentry *root)
75 {
76 	static const struct intel_gt_debugfs_file files[] = {
77 		{ "guc_info", &guc_info_fops, NULL },
78 		{ "guc_registered_contexts", &guc_registered_contexts_fops, NULL },
79 		{ "guc_slpc_info", &guc_slpc_info_fops, &intel_eval_slpc_support},
80 	};
81 
82 	if (!intel_guc_is_supported(guc))
83 		return;
84 
85 	intel_gt_debugfs_register_files(root, files, ARRAY_SIZE(files), guc);
86 	intel_guc_log_debugfs_register(&guc->log, root);
87 }
88