diff options
author | Terje Bergstrom <tbergstrom@nvidia.com> | 2018-04-18 15:59:00 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-06-15 20:47:31 -0400 |
commit | 2a2c16af5f9f1ccfc93a13e820d5381e5c881e92 (patch) | |
tree | 2e5d7b042270a649978e5bb540857012c85fb5b5 /drivers/gpu/nvgpu/common/linux/debug.c | |
parent | 98d996f4ffb0137d119b5849cae46d7b7e5693e1 (diff) |
gpu: nvgpu: Move Linux files away from common
Move all Linux source code files to drivers/gpu/nvgpu/os/linux from
drivers/gpu/nvgpu/common/linux. This changes the meaning of common
to be OS independent.
JIRA NVGPU-598
JIRA NVGPU-601
Change-Id: Ib7f2a43d3688bb0d0b7dcc48469a6783fd988ce9
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1747714
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/debug.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/debug.c | 452 |
1 files changed, 0 insertions, 452 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/debug.c b/drivers/gpu/nvgpu/common/linux/debug.c deleted file mode 100644 index 8738f3e7..00000000 --- a/drivers/gpu/nvgpu/common/linux/debug.c +++ /dev/null | |||
@@ -1,452 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2017-2018 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 "os_linux.h" | ||
26 | #include "platform_gk20a.h" | ||
27 | |||
28 | #include "gk20a/gk20a.h" | ||
29 | |||
30 | #include <linux/debugfs.h> | ||
31 | #include <linux/seq_file.h> | ||
32 | #include <linux/uaccess.h> | ||
33 | |||
34 | #include <nvgpu/debug.h> | ||
35 | |||
36 | unsigned int gk20a_debug_trace_cmdbuf; | ||
37 | |||
38 | static inline void gk20a_debug_write_printk(void *ctx, const char *str, | ||
39 | size_t len) | ||
40 | { | ||
41 | pr_info("%s", str); | ||
42 | } | ||
43 | |||
44 | static inline void gk20a_debug_write_to_seqfile(void *ctx, const char *str, | ||
45 | size_t len) | ||
46 | { | ||
47 | seq_write((struct seq_file *)ctx, str, len); | ||
48 | } | ||
49 | |||
50 | void gk20a_debug_output(struct gk20a_debug_output *o, | ||
51 | const char *fmt, ...) | ||
52 | { | ||
53 | va_list args; | ||
54 | int len; | ||
55 | |||
56 | va_start(args, fmt); | ||
57 | len = vsnprintf(o->buf, sizeof(o->buf), fmt, args); | ||
58 | va_end(args); | ||
59 | o->fn(o->ctx, o->buf, len); | ||
60 | } | ||
61 | |||
62 | static int gk20a_gr_dump_regs(struct gk20a *g, | ||
63 | struct gk20a_debug_output *o) | ||
64 | { | ||
65 | if (g->ops.gr.dump_gr_regs) | ||
66 | gr_gk20a_elpg_protected_call(g, g->ops.gr.dump_gr_regs(g, o)); | ||
67 | |||
68 | return 0; | ||
69 | } | ||
70 | |||
71 | int gk20a_gr_debug_dump(struct gk20a *g) | ||
72 | { | ||
73 | struct gk20a_debug_output o = { | ||
74 | .fn = gk20a_debug_write_printk | ||
75 | }; | ||
76 | |||
77 | gk20a_gr_dump_regs(g, &o); | ||
78 | |||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | static int gk20a_gr_debug_show(struct seq_file *s, void *unused) | ||
83 | { | ||
84 | struct device *dev = s->private; | ||
85 | struct gk20a *g = gk20a_get_platform(dev)->g; | ||
86 | struct gk20a_debug_output o = { | ||
87 | .fn = gk20a_debug_write_to_seqfile, | ||
88 | .ctx = s, | ||
89 | }; | ||
90 | int err; | ||
91 | |||
92 | err = gk20a_busy(g); | ||
93 | if (err) { | ||
94 | nvgpu_err(g, "failed to power on gpu: %d", err); | ||
95 | return -EINVAL; | ||
96 | } | ||
97 | |||
98 | gk20a_gr_dump_regs(g, &o); | ||
99 | |||
100 | gk20a_idle(g); | ||
101 | |||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | void gk20a_debug_dump(struct gk20a *g) | ||
106 | { | ||
107 | struct gk20a_platform *platform = gk20a_get_platform(dev_from_gk20a(g)); | ||
108 | struct gk20a_debug_output o = { | ||
109 | .fn = gk20a_debug_write_printk | ||
110 | }; | ||
111 | |||
112 | if (platform->dump_platform_dependencies) | ||
113 | platform->dump_platform_dependencies(dev_from_gk20a(g)); | ||
114 | |||
115 | /* HAL only initialized after 1st power-on */ | ||
116 | if (g->ops.debug.show_dump) | ||
117 | g->ops.debug.show_dump(g, &o); | ||
118 | } | ||
119 | |||
120 | static int gk20a_debug_show(struct seq_file *s, void *unused) | ||
121 | { | ||
122 | struct device *dev = s->private; | ||
123 | struct gk20a_debug_output o = { | ||
124 | .fn = gk20a_debug_write_to_seqfile, | ||
125 | .ctx = s, | ||
126 | }; | ||
127 | struct gk20a *g; | ||
128 | int err; | ||
129 | |||
130 | g = gk20a_get_platform(dev)->g; | ||
131 | |||
132 | err = gk20a_busy(g); | ||
133 | if (err) { | ||
134 | nvgpu_err(g, "failed to power on gpu: %d", err); | ||
135 | return -EFAULT; | ||
136 | } | ||
137 | |||
138 | /* HAL only initialized after 1st power-on */ | ||
139 | if (g->ops.debug.show_dump) | ||
140 | g->ops.debug.show_dump(g, &o); | ||
141 | |||
142 | gk20a_idle(g); | ||
143 | return 0; | ||
144 | } | ||
145 | |||
146 | static int gk20a_gr_debug_open(struct inode *inode, struct file *file) | ||
147 | { | ||
148 | return single_open(file, gk20a_gr_debug_show, inode->i_private); | ||
149 | } | ||
150 | |||
151 | static int gk20a_debug_open(struct inode *inode, struct file *file) | ||
152 | { | ||
153 | return single_open(file, gk20a_debug_show, inode->i_private); | ||
154 | } | ||
155 | |||
156 | static const struct file_operations gk20a_gr_debug_fops = { | ||
157 | .open = gk20a_gr_debug_open, | ||
158 | .read = seq_read, | ||
159 | .llseek = seq_lseek, | ||
160 | .release = single_release, | ||
161 | }; | ||
162 | |||
163 | static const struct file_operations gk20a_debug_fops = { | ||
164 | .open = gk20a_debug_open, | ||
165 | .read = seq_read, | ||
166 | .llseek = seq_lseek, | ||
167 | .release = single_release, | ||
168 | }; | ||
169 | |||
170 | void gk20a_debug_show_dump(struct gk20a *g, struct gk20a_debug_output *o) | ||
171 | { | ||
172 | g->ops.fifo.dump_pbdma_status(g, o); | ||
173 | g->ops.fifo.dump_eng_status(g, o); | ||
174 | |||
175 | gk20a_debug_dump_all_channel_status_ramfc(g, o); | ||
176 | } | ||
177 | |||
178 | static ssize_t disable_bigpage_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) | ||
179 | { | ||
180 | char buf[3]; | ||
181 | struct gk20a *g = file->private_data; | ||
182 | |||
183 | if (g->mm.disable_bigpage) | ||
184 | buf[0] = 'Y'; | ||
185 | else | ||
186 | buf[0] = 'N'; | ||
187 | buf[1] = '\n'; | ||
188 | buf[2] = 0x00; | ||
189 | return simple_read_from_buffer(user_buf, count, ppos, buf, 2); | ||
190 | } | ||
191 | |||
192 | static ssize_t disable_bigpage_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) | ||
193 | { | ||
194 | char buf[32]; | ||
195 | int buf_size; | ||
196 | bool bv; | ||
197 | struct gk20a *g = file->private_data; | ||
198 | |||
199 | buf_size = min(count, (sizeof(buf)-1)); | ||
200 | if (copy_from_user(buf, user_buf, buf_size)) | ||
201 | return -EFAULT; | ||
202 | |||
203 | if (strtobool(buf, &bv) == 0) { | ||
204 | g->mm.disable_bigpage = bv; | ||
205 | gk20a_init_gpu_characteristics(g); | ||
206 | } | ||
207 | |||
208 | return count; | ||
209 | } | ||
210 | |||
211 | static struct file_operations disable_bigpage_fops = { | ||
212 | .open = simple_open, | ||
213 | .read = disable_bigpage_read, | ||
214 | .write = disable_bigpage_write, | ||
215 | }; | ||
216 | |||
217 | static int railgate_residency_show(struct seq_file *s, void *data) | ||
218 | { | ||
219 | struct gk20a *g = s->private; | ||
220 | struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g)); | ||
221 | unsigned long time_since_last_state_transition_ms; | ||
222 | unsigned long total_rail_gate_time_ms; | ||
223 | unsigned long total_rail_ungate_time_ms; | ||
224 | |||
225 | if (platform->is_railgated(dev_from_gk20a(g))) { | ||
226 | time_since_last_state_transition_ms = | ||
227 | jiffies_to_msecs(jiffies - | ||
228 | g->pstats.last_rail_gate_complete); | ||
229 | total_rail_ungate_time_ms = g->pstats.total_rail_ungate_time_ms; | ||
230 | total_rail_gate_time_ms = | ||
231 | g->pstats.total_rail_gate_time_ms + | ||
232 | time_since_last_state_transition_ms; | ||
233 | } else { | ||
234 | time_since_last_state_transition_ms = | ||
235 | jiffies_to_msecs(jiffies - | ||
236 | g->pstats.last_rail_ungate_complete); | ||
237 | total_rail_gate_time_ms = g->pstats.total_rail_gate_time_ms; | ||
238 | total_rail_ungate_time_ms = | ||
239 | g->pstats.total_rail_ungate_time_ms + | ||
240 | time_since_last_state_transition_ms; | ||
241 | } | ||
242 | |||
243 | seq_printf(s, "Time with Rails Gated: %lu ms\n" | ||
244 | "Time with Rails UnGated: %lu ms\n" | ||
245 | "Total railgating cycles: %lu\n", | ||
246 | total_rail_gate_time_ms, | ||
247 | total_rail_ungate_time_ms, | ||
248 | g->pstats.railgating_cycle_count - 1); | ||
249 | return 0; | ||
250 | |||
251 | } | ||
252 | |||
253 | static int railgate_residency_open(struct inode *inode, struct file *file) | ||
254 | { | ||
255 | return single_open(file, railgate_residency_show, inode->i_private); | ||
256 | } | ||
257 | |||
258 | static const struct file_operations railgate_residency_fops = { | ||
259 | .open = railgate_residency_open, | ||
260 | .read = seq_read, | ||
261 | .llseek = seq_lseek, | ||
262 | .release = single_release, | ||
263 | }; | ||
264 | |||
265 | static int gk20a_railgating_debugfs_init(struct gk20a *g) | ||
266 | { | ||
267 | struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); | ||
268 | struct dentry *d; | ||
269 | |||
270 | d = debugfs_create_file( | ||
271 | "railgate_residency", S_IRUGO|S_IWUSR, l->debugfs, g, | ||
272 | &railgate_residency_fops); | ||
273 | if (!d) | ||
274 | return -ENOMEM; | ||
275 | |||
276 | return 0; | ||
277 | } | ||
278 | static ssize_t timeouts_enabled_read(struct file *file, | ||
279 | char __user *user_buf, size_t count, loff_t *ppos) | ||
280 | { | ||
281 | char buf[3]; | ||
282 | struct gk20a *g = file->private_data; | ||
283 | |||
284 | if (nvgpu_is_timeouts_enabled(g)) | ||
285 | buf[0] = 'Y'; | ||
286 | else | ||
287 | buf[0] = 'N'; | ||
288 | buf[1] = '\n'; | ||
289 | buf[2] = 0x00; | ||
290 | return simple_read_from_buffer(user_buf, count, ppos, buf, 2); | ||
291 | } | ||
292 | |||
293 | static ssize_t timeouts_enabled_write(struct file *file, | ||
294 | const char __user *user_buf, size_t count, loff_t *ppos) | ||
295 | { | ||
296 | char buf[3]; | ||
297 | int buf_size; | ||
298 | bool timeouts_enabled; | ||
299 | struct gk20a *g = file->private_data; | ||
300 | |||
301 | buf_size = min(count, (sizeof(buf)-1)); | ||
302 | if (copy_from_user(buf, user_buf, buf_size)) | ||
303 | return -EFAULT; | ||
304 | |||
305 | if (strtobool(buf, &timeouts_enabled) == 0) { | ||
306 | nvgpu_mutex_acquire(&g->dbg_sessions_lock); | ||
307 | if (timeouts_enabled == false) { | ||
308 | /* requesting to disable timeouts */ | ||
309 | if (g->timeouts_disabled_by_user == false) { | ||
310 | nvgpu_atomic_inc(&g->timeouts_disabled_refcount); | ||
311 | g->timeouts_disabled_by_user = true; | ||
312 | } | ||
313 | } else { | ||
314 | /* requesting to enable timeouts */ | ||
315 | if (g->timeouts_disabled_by_user == true) { | ||
316 | nvgpu_atomic_dec(&g->timeouts_disabled_refcount); | ||
317 | g->timeouts_disabled_by_user = false; | ||
318 | } | ||
319 | } | ||
320 | nvgpu_mutex_release(&g->dbg_sessions_lock); | ||
321 | } | ||
322 | |||
323 | return count; | ||
324 | } | ||
325 | |||
326 | static const struct file_operations timeouts_enabled_fops = { | ||
327 | .open = simple_open, | ||
328 | .read = timeouts_enabled_read, | ||
329 | .write = timeouts_enabled_write, | ||
330 | }; | ||
331 | |||
332 | void gk20a_debug_init(struct gk20a *g, const char *debugfs_symlink) | ||
333 | { | ||
334 | struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); | ||
335 | struct device *dev = dev_from_gk20a(g); | ||
336 | |||
337 | l->debugfs = debugfs_create_dir(dev_name(dev), NULL); | ||
338 | if (!l->debugfs) | ||
339 | return; | ||
340 | |||
341 | if (debugfs_symlink) | ||
342 | l->debugfs_alias = | ||
343 | debugfs_create_symlink(debugfs_symlink, | ||
344 | NULL, dev_name(dev)); | ||
345 | |||
346 | debugfs_create_file("status", S_IRUGO, l->debugfs, | ||
347 | dev, &gk20a_debug_fops); | ||
348 | debugfs_create_file("gr_status", S_IRUGO, l->debugfs, | ||
349 | dev, &gk20a_gr_debug_fops); | ||
350 | debugfs_create_u32("trace_cmdbuf", S_IRUGO|S_IWUSR, | ||
351 | l->debugfs, &gk20a_debug_trace_cmdbuf); | ||
352 | |||
353 | debugfs_create_u32("ch_wdt_timeout_ms", S_IRUGO|S_IWUSR, | ||
354 | l->debugfs, &g->ch_wdt_timeout_ms); | ||
355 | |||
356 | debugfs_create_u32("disable_syncpoints", S_IRUGO, | ||
357 | l->debugfs, &g->disable_syncpoints); | ||
358 | |||
359 | /* New debug logging API. */ | ||
360 | debugfs_create_u64("log_mask", S_IRUGO|S_IWUSR, | ||
361 | l->debugfs, &g->log_mask); | ||
362 | debugfs_create_u32("log_trace", S_IRUGO|S_IWUSR, | ||
363 | l->debugfs, &g->log_trace); | ||
364 | |||
365 | l->debugfs_ltc_enabled = | ||
366 | debugfs_create_bool("ltc_enabled", S_IRUGO|S_IWUSR, | ||
367 | l->debugfs, | ||
368 | &g->mm.ltc_enabled_target); | ||
369 | |||
370 | l->debugfs_gr_idle_timeout_default = | ||
371 | debugfs_create_u32("gr_idle_timeout_default_us", | ||
372 | S_IRUGO|S_IWUSR, l->debugfs, | ||
373 | &g->gr_idle_timeout_default); | ||
374 | l->debugfs_timeouts_enabled = | ||
375 | debugfs_create_file("timeouts_enabled", | ||
376 | S_IRUGO|S_IWUSR, | ||
377 | l->debugfs, | ||
378 | g, | ||
379 | &timeouts_enabled_fops); | ||
380 | |||
381 | l->debugfs_disable_bigpage = | ||
382 | debugfs_create_file("disable_bigpage", | ||
383 | S_IRUGO|S_IWUSR, | ||
384 | l->debugfs, | ||
385 | g, | ||
386 | &disable_bigpage_fops); | ||
387 | |||
388 | l->debugfs_timeslice_low_priority_us = | ||
389 | debugfs_create_u32("timeslice_low_priority_us", | ||
390 | S_IRUGO|S_IWUSR, | ||
391 | l->debugfs, | ||
392 | &g->timeslice_low_priority_us); | ||
393 | l->debugfs_timeslice_medium_priority_us = | ||
394 | debugfs_create_u32("timeslice_medium_priority_us", | ||
395 | S_IRUGO|S_IWUSR, | ||
396 | l->debugfs, | ||
397 | &g->timeslice_medium_priority_us); | ||
398 | l->debugfs_timeslice_high_priority_us = | ||
399 | debugfs_create_u32("timeslice_high_priority_us", | ||
400 | S_IRUGO|S_IWUSR, | ||
401 | l->debugfs, | ||
402 | &g->timeslice_high_priority_us); | ||
403 | l->debugfs_runlist_interleave = | ||
404 | debugfs_create_bool("runlist_interleave", | ||
405 | S_IRUGO|S_IWUSR, | ||
406 | l->debugfs, | ||
407 | &g->runlist_interleave); | ||
408 | l->debugfs_force_preemption_gfxp = | ||
409 | debugfs_create_bool("force_preemption_gfxp", S_IRUGO|S_IWUSR, | ||
410 | l->debugfs, | ||
411 | &g->gr.ctx_vars.force_preemption_gfxp); | ||
412 | |||
413 | l->debugfs_force_preemption_cilp = | ||
414 | debugfs_create_bool("force_preemption_cilp", S_IRUGO|S_IWUSR, | ||
415 | l->debugfs, | ||
416 | &g->gr.ctx_vars.force_preemption_cilp); | ||
417 | |||
418 | l->debugfs_dump_ctxsw_stats = | ||
419 | debugfs_create_bool("dump_ctxsw_stats_on_channel_close", | ||
420 | S_IRUGO|S_IWUSR, l->debugfs, | ||
421 | &g->gr.ctx_vars.dump_ctxsw_stats_on_channel_close); | ||
422 | |||
423 | gr_gk20a_debugfs_init(g); | ||
424 | gk20a_pmu_debugfs_init(g); | ||
425 | gk20a_railgating_debugfs_init(g); | ||
426 | #ifdef CONFIG_NVGPU_SUPPORT_CDE | ||
427 | gk20a_cde_debugfs_init(g); | ||
428 | #endif | ||
429 | gk20a_ce_debugfs_init(g); | ||
430 | nvgpu_alloc_debugfs_init(g); | ||
431 | nvgpu_hal_debugfs_init(g); | ||
432 | gk20a_fifo_debugfs_init(g); | ||
433 | gk20a_sched_debugfs_init(g); | ||
434 | #ifdef CONFIG_NVGPU_TRACK_MEM_USAGE | ||
435 | nvgpu_kmem_debugfs_init(g); | ||
436 | #endif | ||
437 | if (g->pci_vendor_id) | ||
438 | nvgpu_xve_debugfs_init(g); | ||
439 | } | ||
440 | |||
441 | void gk20a_debug_deinit(struct gk20a *g) | ||
442 | { | ||
443 | struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); | ||
444 | |||
445 | if (!l->debugfs) | ||
446 | return; | ||
447 | |||
448 | gk20a_fifo_debugfs_deinit(g); | ||
449 | |||
450 | debugfs_remove_recursive(l->debugfs); | ||
451 | debugfs_remove(l->debugfs_alias); | ||
452 | } | ||