aboutsummaryrefslogtreecommitdiffstats
path: root/include/os/linux/debug_fifo.c
diff options
context:
space:
mode:
authorJoshua Bakita <bakitajoshua@gmail.com>2024-09-25 16:09:09 -0400
committerJoshua Bakita <bakitajoshua@gmail.com>2024-09-25 16:09:09 -0400
commitf347fde22f1297e4f022600d201780d5ead78114 (patch)
tree76be305d6187003a1e0486ff6e91efb1062ae118 /include/os/linux/debug_fifo.c
parent8340d234d78a7d0f46c11a584de538148b78b7cb (diff)
Delete no-longer-needed nvgpu headers
The dependency on these was removed in commit 8340d234.
Diffstat (limited to 'include/os/linux/debug_fifo.c')
-rw-r--r--include/os/linux/debug_fifo.c376
1 files changed, 0 insertions, 376 deletions
diff --git a/include/os/linux/debug_fifo.c b/include/os/linux/debug_fifo.c
deleted file mode 100644
index 98da8bc..0000000
--- a/include/os/linux/debug_fifo.c
+++ /dev/null
@@ -1,376 +0,0 @@
1/*
2 * Copyright (C) 2017-2020 NVIDIA Corporation. All rights reserved.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#include "debug_fifo.h"
16#include "os_linux.h"
17
18#include <linux/debugfs.h>
19#include <linux/seq_file.h>
20
21#include <nvgpu/sort.h>
22#include <nvgpu/timers.h>
23#include <nvgpu/channel.h>
24
25void __gk20a_fifo_profile_free(struct nvgpu_ref *ref);
26
27static void *gk20a_fifo_sched_debugfs_seq_start(
28 struct seq_file *s, loff_t *pos)
29{
30 struct gk20a *g = s->private;
31 struct fifo_gk20a *f = &g->fifo;
32
33 if (*pos >= f->num_channels)
34 return NULL;
35
36 return &f->channel[*pos];
37}
38
39static void *gk20a_fifo_sched_debugfs_seq_next(
40 struct seq_file *s, void *v, loff_t *pos)
41{
42 struct gk20a *g = s->private;
43 struct fifo_gk20a *f = &g->fifo;
44
45 ++(*pos);
46 if (*pos >= f->num_channels)
47 return NULL;
48
49 return &f->channel[*pos];
50}
51
52static void gk20a_fifo_sched_debugfs_seq_stop(
53 struct seq_file *s, void *v)
54{
55}
56
57static int gk20a_fifo_sched_debugfs_seq_show(
58 struct seq_file *s, void *v)
59{
60 struct gk20a *g = s->private;
61 struct fifo_gk20a *f = &g->fifo;
62 struct channel_gk20a *ch = v;
63 struct tsg_gk20a *tsg = NULL;
64
65 struct fifo_engine_info_gk20a *engine_info;
66 struct fifo_runlist_info_gk20a *runlist;
67 u32 runlist_id;
68 int ret = SEQ_SKIP;
69 u32 engine_id;
70
71 engine_id = gk20a_fifo_get_gr_engine_id(g);
72 engine_info = (f->engine_info + engine_id);
73 runlist_id = engine_info->runlist_id;
74 runlist = &f->runlist_info[runlist_id];
75
76 if (ch == f->channel) {
77 seq_puts(s, "chid tsgid pid timeslice timeout interleave graphics_preempt compute_preempt\n");
78 seq_puts(s, " (usecs) (msecs)\n");
79 ret = 0;
80 }
81
82 if (!test_bit(ch->chid, runlist->active_channels))
83 return ret;
84
85 if (gk20a_channel_get(ch)) {
86 tsg = tsg_gk20a_from_ch(ch);
87
88 if (tsg)
89 seq_printf(s, "%-8d %-8d %-8d %-9d %-8d %-10d %-8d %-8d\n",
90 ch->chid,
91 ch->tsgid,
92 ch->tgid,
93 tsg->timeslice_us,
94 ch->timeout_ms_max,
95 tsg->interleave_level,
96 tsg->gr_ctx.graphics_preempt_mode,
97 tsg->gr_ctx.compute_preempt_mode);
98 gk20a_channel_put(ch);
99 }
100 return 0;
101}
102
103static const struct seq_operations gk20a_fifo_sched_debugfs_seq_ops = {
104 .start = gk20a_fifo_sched_debugfs_seq_start,
105 .next = gk20a_fifo_sched_debugfs_seq_next,
106 .stop = gk20a_fifo_sched_debugfs_seq_stop,
107 .show = gk20a_fifo_sched_debugfs_seq_show
108};
109
110static int gk20a_fifo_sched_debugfs_open(struct inode *inode,
111 struct file *file)
112{
113 struct gk20a *g = inode->i_private;
114 int err;
115
116 err = seq_open(file, &gk20a_fifo_sched_debugfs_seq_ops);
117 if (err)
118 return err;
119
120 nvgpu_log(g, gpu_dbg_info, "i_private=%p", inode->i_private);
121
122 ((struct seq_file *)file->private_data)->private = inode->i_private;
123 return 0;
124};
125
126/*
127 * The file operations structure contains our open function along with
128 * set of the canned seq_ ops.
129 */
130static const struct file_operations gk20a_fifo_sched_debugfs_fops = {
131 .owner = THIS_MODULE,
132 .open = gk20a_fifo_sched_debugfs_open,
133 .read = seq_read,
134 .llseek = seq_lseek,
135 .release = seq_release
136};
137
138static int gk20a_fifo_profile_enable(void *data, u64 val)
139{
140 struct gk20a *g = (struct gk20a *) data;
141 struct fifo_gk20a *f = &g->fifo;
142
143
144 nvgpu_mutex_acquire(&f->profile.lock);
145 if (val == 0) {
146 if (f->profile.enabled) {
147 f->profile.enabled = false;
148 nvgpu_ref_put(&f->profile.ref,
149 __gk20a_fifo_profile_free);
150 }
151 } else {
152 if (!f->profile.enabled) {
153 /* not kref init as it can have a running condition if
154 * we enable/disable/enable while kickoff is happening
155 */
156 if (!nvgpu_ref_get_unless_zero(&f->profile.ref)) {
157 f->profile.data = nvgpu_vzalloc(g,
158 FIFO_PROFILING_ENTRIES *
159 sizeof(struct fifo_profile_gk20a));
160 f->profile.sorted = nvgpu_vzalloc(g,
161 FIFO_PROFILING_ENTRIES *
162 sizeof(u64));
163 if (!(f->profile.data && f->profile.sorted)) {
164 nvgpu_vfree(g, f->profile.data);
165 nvgpu_vfree(g, f->profile.sorted);
166 nvgpu_mutex_release(&f->profile.lock);
167 return -ENOMEM;
168 }
169 nvgpu_ref_init(&f->profile.ref);
170 }
171 atomic_set(&f->profile.get.atomic_var, 0);
172 f->profile.enabled = true;
173 }
174 }
175 nvgpu_mutex_release(&f->profile.lock);
176
177 return 0;
178}
179
180DEFINE_SIMPLE_ATTRIBUTE(
181 gk20a_fifo_profile_enable_debugfs_fops,
182 NULL,
183 gk20a_fifo_profile_enable,
184 "%llu\n"
185);
186
187static int __profile_cmp(const void *a, const void *b)
188{
189 return *((unsigned long long *) a) - *((unsigned long long *) b);
190}
191
192/*
193 * This uses about 800b in the stack, but the function using it is not part
194 * of a callstack where much memory is being used, so it is fine
195 */
196#define PERCENTILE_WIDTH 5
197#define PERCENTILE_RANGES (100/PERCENTILE_WIDTH)
198
199static unsigned int __gk20a_fifo_create_stats(struct gk20a *g,
200 u64 *percentiles, u32 index_end, u32 index_start)
201{
202 unsigned int nelem = 0;
203 unsigned int index;
204 struct fifo_profile_gk20a *profile;
205
206 for (index = 0; index < FIFO_PROFILING_ENTRIES; index++) {
207 profile = &g->fifo.profile.data[index];
208
209 if (profile->timestamp[index_end] >
210 profile->timestamp[index_start]) {
211 /* This is a valid element */
212 g->fifo.profile.sorted[nelem] =
213 profile->timestamp[index_end] -
214