aboutsummaryrefslogtreecommitdiffstats
path: root/include/os/linux/debug.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.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.c')
-rw-r--r--include/os/linux/debug.c457
1 files changed, 0 insertions, 457 deletions
diff --git a/include/os/linux/debug.c b/include/os/linux/debug.c
deleted file mode 100644
index b8c4596..0000000
--- a/include/os/linux/debug.c
+++ /dev/null
@@ -1,457 +0,0 @@
1/*
2 * Copyright (C) 2017-2021 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_cde.h"
16#include "debug_ce.h"
17#include "debug_fifo.h"
18#include "debug_gr.h"
19#include "debug_allocator.h"
20#include "debug_kmem.h"
21#include "debug_pmu.h"
22#include "debug_sched.h"
23#include "debug_hal.h"
24#include "debug_xve.h"
25#include "debug_ltc.h"
26#include "debug_bios.h"
27#include "os_linux.h"
28#include "platform_gk20a.h"
29
30#include <nvgpu/gk20a.h>
31
32#include <linux/debugfs.h>
33#include <linux/seq_file.h>
34#include <linux/uaccess.h>
35
36#include <nvgpu/debug.h>
37
38unsigned int gk20a_debug_trace_cmdbuf;
39
40static inline void gk20a_debug_write_printk(void *ctx, const char *str,
41 size_t len)
42{
43 pr_info("%s", str);
44}
45
46static inline void gk20a_debug_write_to_seqfile(void *ctx, const char *str,
47 size_t len)
48{
49 seq_write((struct seq_file *)ctx, str, len);
50}
51
52void gk20a_debug_output(struct gk20a_debug_output *o,
53 const char *fmt, ...)
54{
55 va_list args;
56 int len;
57
58 va_start(args, fmt);
59 len = vsnprintf(o->buf, sizeof(o->buf), fmt, args);
60 va_end(args);
61 o->fn(o->ctx, o->buf, len);
62}
63
64static int gk20a_gr_dump_regs(struct gk20a *g,
65 struct gk20a_debug_output *o)
66{
67 if (g->ops.gr.dump_gr_regs)
68 gr_gk20a_elpg_protected_call(g, g->ops.gr.dump_gr_regs(g, o));
69
70 return 0;
71}
72
73int gk20a_gr_debug_dump(struct gk20a *g)
74{
75 struct gk20a_debug_output o = {
76 .fn = gk20a_debug_write_printk
77 };
78
79 gk20a_gr_dump_regs(g, &o);
80
81 return 0;
82}
83
84static int gk20a_gr_debug_show(struct seq_file *s, void *unused)
85{
86 struct device *dev = s->private;
87 struct gk20a *g = gk20a_get_platform(dev)->g;
88 struct gk20a_debug_output o = {
89 .fn = gk20a_debug_write_to_seqfile,
90 .ctx = s,
91 };
92 int err;
93
94 err = gk20a_busy(g);
95 if (err) {
96 nvgpu_err(g, "failed to power on gpu: %d", err);
97 return -EINVAL;
98 }
99
100 gk20a_gr_dump_regs(g, &o);
101
102 gk20a_idle(g);
103
104 return 0;
105}
106
107void gk20a_debug_dump(struct gk20a *g)
108{
109 struct gk20a_platform *platform = gk20a_get_platform(dev_from_gk20a(g));
110 struct gk20a_debug_output o = {
111 .fn = gk20a_debug_write_printk
112 };
113
114 if (platform->dump_platform_dependencies)
115 platform->dump_platform_dependencies(dev_from_gk20a(g));
116
117 /* HAL only initialized after 1st power-on */
118 if (g->ops.debug.show_dump)
119 g->ops.debug.show_dump(g, &o);
120}
121
122static int gk20a_debug_show(struct seq_file *s, void *unused)
123{
124 struct device *dev = s->private;
125 struct gk20a_debug_output o = {
126 .fn = gk20a_debug_write_to_seqfile,
127 .ctx = s,
128 };
129 struct gk20a *g;
130 int err;
131
132 g = gk20a_get_platform(dev)->g;
133
134 err = gk20a_busy(g);
135 if (err) {
136 nvgpu_err(g, "failed to power on gpu: %d", err);
137 return -EFAULT;
138 }
139
140 /* HAL only initialized after 1st power-on */
141 if (g->ops.debug.show_dump)
142 g->ops.debug.show_dump(g, &o);
143
144 gk20a_idle(g);
145 return 0;
146}
147
148static int gk20a_gr_debug_open(struct inode *inode, struct file *file)
149{
150 return single_open(file, gk20a_gr_debug_show, inode->i_private);
151}
152
153static int gk20a_debug_open(struct inode *inode, struct file *file)
154{
155 return single_open(file, gk20a_debug_show, inode->i_private);
156}
157
158static const struct file_operations gk20a_gr_debug_fops = {
159 .open = gk20a_gr_debug_open,
160 .read = seq_read,
161 .llseek = seq_lseek,
162 .release = single_release,
163};
164
165static const struct file_operations gk20a_debug_fops = {
166 .open = gk20a_debug_open,
167 .read = seq_read,
168 .llseek = seq_lseek,
169 .release = single_release,
170};
171
172void gk20a_debug_show_dump(struct gk20a *g, struct gk20a_debug_output *o)
173{
174 g->ops.fifo.dump_pbdma_status(g, o);
175 g->ops.fifo.dump_eng_status(g, o);
176
177 gk20a_debug_dump_all_channel_status_ramfc(g, o);
178}
179
180static ssize_t disable_bigpage_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos)
181{
182 char buf[3];
183 struct gk20a *g = file->private_data;
184
185 if (g->mm.disable_bigpage)
186 buf[0] = 'Y';
187 else
188 buf[0] = 'N';
189 buf[1] = '\n';
190 buf[2] = 0x00;
191 return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
192}
193
194static ssize_t disable_bigpage_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos)
195{
196 char buf[32];
197 int buf_size;
198 bool bv;
199 struct gk20a *g = file->private_data;
200
201 buf_size = min(count, (sizeof(buf)-1));
202 if (copy_from_user(buf, user_buf, buf_size))
203 return -EFAULT;
204
205 if (strtobool(buf, &bv) == 0) {
206 g->mm.disable_bigpage = bv;
207 gk20a_init_gpu_characteristics(g);
208 }
209
210 return count;
211}
212
213static struct file_operations disable_bigpage_fops = {
214 .open = simple_open,
215 .read = disable_bigpage_read,
216 .write = disable_bigpage_write,
217};
218
219static int railgate_residency_show(struct seq_file *s, void *data)
220{
221 struct gk20a *g = s->private;
222 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
223 unsigned long time_since_last_state_transition_ms;
224 unsigned long total_rail_gate_time_ms;