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 
17 #ifdef notyet
18 
guc_info_show(struct seq_file * m,void * data)19 static int guc_info_show(struct seq_file *m, void *data)
20 {
21 	struct intel_guc *guc = m->private;
22 	struct drm_printer p = drm_seq_file_printer(m);
23 
24 	if (!intel_guc_is_supported(guc))
25 		return -ENODEV;
26 
27 	intel_guc_load_status(guc, &p);
28 	drm_puts(&p, "\n");
29 	intel_guc_log_info(&guc->log, &p);
30 
31 	if (!intel_guc_submission_is_used(guc))
32 		return 0;
33 
34 	intel_guc_ct_print_info(&guc->ct, &p);
35 	intel_guc_submission_print_info(guc, &p);
36 	intel_guc_ads_print_policy_info(guc, &p);
37 
38 	return 0;
39 }
40 DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(guc_info);
41 
guc_registered_contexts_show(struct seq_file * m,void * data)42 static int guc_registered_contexts_show(struct seq_file *m, void *data)
43 {
44 	struct intel_guc *guc = m->private;
45 	struct drm_printer p = drm_seq_file_printer(m);
46 
47 	if (!intel_guc_submission_is_used(guc))
48 		return -ENODEV;
49 
50 	intel_guc_submission_print_context_info(guc, &p);
51 
52 	return 0;
53 }
54 DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(guc_registered_contexts);
55 
guc_slpc_info_show(struct seq_file * m,void * unused)56 static int guc_slpc_info_show(struct seq_file *m, void *unused)
57 {
58 	struct intel_guc *guc = m->private;
59 	struct intel_guc_slpc *slpc = &guc->slpc;
60 	struct drm_printer p = drm_seq_file_printer(m);
61 
62 	if (!intel_guc_slpc_is_used(guc))
63 		return -ENODEV;
64 
65 	return intel_guc_slpc_print_info(slpc, &p);
66 }
67 DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(guc_slpc_info);
68 
intel_eval_slpc_support(void * data)69 static bool intel_eval_slpc_support(void *data)
70 {
71 	struct intel_guc *guc = (struct intel_guc *)data;
72 
73 	return intel_guc_slpc_is_used(guc);
74 }
75 
guc_sched_disable_delay_ms_get(void * data,u64 * val)76 static int guc_sched_disable_delay_ms_get(void *data, u64 *val)
77 {
78 	struct intel_guc *guc = data;
79 
80 	if (!intel_guc_submission_is_used(guc))
81 		return -ENODEV;
82 
83 	*val = (u64)guc->submission_state.sched_disable_delay_ms;
84 
85 	return 0;
86 }
87 
guc_sched_disable_delay_ms_set(void * data,u64 val)88 static int guc_sched_disable_delay_ms_set(void *data, u64 val)
89 {
90 	struct intel_guc *guc = data;
91 
92 	if (!intel_guc_submission_is_used(guc))
93 		return -ENODEV;
94 
95 	/* clamp to a practical limit, 1 minute is reasonable for a longest delay */
96 	guc->submission_state.sched_disable_delay_ms = min_t(u64, val, 60000);
97 
98 	return 0;
99 }
100 DEFINE_SIMPLE_ATTRIBUTE(guc_sched_disable_delay_ms_fops,
101 			guc_sched_disable_delay_ms_get,
102 			guc_sched_disable_delay_ms_set, "%lld\n");
103 
guc_sched_disable_gucid_threshold_get(void * data,u64 * val)104 static int guc_sched_disable_gucid_threshold_get(void *data, u64 *val)
105 {
106 	struct intel_guc *guc = data;
107 
108 	if (!intel_guc_submission_is_used(guc))
109 		return -ENODEV;
110 
111 	*val = guc->submission_state.sched_disable_gucid_threshold;
112 	return 0;
113 }
114 
guc_sched_disable_gucid_threshold_set(void * data,u64 val)115 static int guc_sched_disable_gucid_threshold_set(void *data, u64 val)
116 {
117 	struct intel_guc *guc = data;
118 
119 	if (!intel_guc_submission_is_used(guc))
120 		return -ENODEV;
121 
122 	if (val > intel_guc_sched_disable_gucid_threshold_max(guc))
123 		guc->submission_state.sched_disable_gucid_threshold =
124 			intel_guc_sched_disable_gucid_threshold_max(guc);
125 	else
126 		guc->submission_state.sched_disable_gucid_threshold = val;
127 
128 	return 0;
129 }
130 DEFINE_SIMPLE_ATTRIBUTE(guc_sched_disable_gucid_threshold_fops,
131 			guc_sched_disable_gucid_threshold_get,
132 			guc_sched_disable_gucid_threshold_set, "%lld\n");
133 
134 #endif
135 
intel_guc_debugfs_register(struct intel_guc * guc,struct dentry * root)136 void intel_guc_debugfs_register(struct intel_guc *guc, struct dentry *root)
137 {
138 	STUB();
139 #ifdef notyet
140 	static const struct intel_gt_debugfs_file files[] = {
141 		{ "guc_info", &guc_info_fops, NULL },
142 		{ "guc_registered_contexts", &guc_registered_contexts_fops, NULL },
143 		{ "guc_slpc_info", &guc_slpc_info_fops, &intel_eval_slpc_support},
144 		{ "guc_sched_disable_delay_ms", &guc_sched_disable_delay_ms_fops, NULL },
145 		{ "guc_sched_disable_gucid_threshold", &guc_sched_disable_gucid_threshold_fops,
146 		   NULL },
147 	};
148 
149 	if (!intel_guc_is_supported(guc))
150 		return;
151 
152 	intel_gt_debugfs_register_files(root, files, ARRAY_SIZE(files), guc);
153 	intel_guc_log_debugfs_register(&guc->log, root);
154 #endif
155 }
156