summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/os/linux/debug_ltc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/os/linux/debug_ltc.c')
-rw-r--r--drivers/gpu/nvgpu/os/linux/debug_ltc.c93
1 files changed, 93 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/os/linux/debug_ltc.c b/drivers/gpu/nvgpu/os/linux/debug_ltc.c
new file mode 100644
index 00000000..88fb45f4
--- /dev/null
+++ b/drivers/gpu/nvgpu/os/linux/debug_ltc.c
@@ -0,0 +1,93 @@
1/*
2 * Copyright (C) 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_ltc.h"
16#include "os_linux.h"
17#include "gk20a/gk20a.h"
18
19#include <linux/debugfs.h>
20#include <linux/uaccess.h>
21
22static ssize_t ltc_intr_illegal_compstat_read(struct file *file,
23 char __user *user_buf, size_t count, loff_t *ppos)
24{
25 char buf[3];
26 struct gk20a *g = file->private_data;
27
28 if (g->ltc_intr_en_illegal_compstat)
29 buf[0] = 'Y';
30 else
31 buf[0] = 'N';
32 buf[1] = '\n';
33 buf[2] = 0x00;
34
35 return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
36}
37
38static ssize_t ltc_intr_illegal_compstat_write(struct file *file,
39 const char __user *user_buf, size_t count, loff_t *ppos)
40{
41 char buf[3];
42 int buf_size;
43 bool intr_illegal_compstat_enabled;
44 struct gk20a *g = file->private_data;
45 int err;
46
47 if (!g->ops.ltc.intr_en_illegal_compstat)
48 return -EINVAL;
49
50 buf_size = min(count, (sizeof(buf)-1));
51 if (copy_from_user(buf, user_buf, buf_size))
52 return -EFAULT;
53
54 err = gk20a_busy(g);
55 if (err)
56 return err;
57
58 if (strtobool(buf, &intr_illegal_compstat_enabled) == 0) {
59 g->ops.ltc.intr_en_illegal_compstat(g,
60 intr_illegal_compstat_enabled);
61 g->ltc_intr_en_illegal_compstat = intr_illegal_compstat_enabled;
62 }
63
64 gk20a_idle(g);
65
66 return buf_size;
67}
68
69static const struct file_operations ltc_intr_illegal_compstat_fops = {
70 .open = simple_open,
71 .read = ltc_intr_illegal_compstat_read,
72 .write = ltc_intr_illegal_compstat_write,
73};
74
75int nvgpu_ltc_debugfs_init(struct gk20a *g)
76{
77 struct dentry *d;
78 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
79 struct dentry *gpu_root = l->debugfs;
80
81 l->debugfs_ltc = debugfs_create_dir("ltc", gpu_root);
82 if (IS_ERR_OR_NULL(l->debugfs_ltc))
83 return -ENODEV;
84
85 /* Debug fs node to enable/disable illegal_compstat */
86 d = debugfs_create_file("intr_illegal_compstat_enable", 0600,
87 l->debugfs_ltc, g,
88 &ltc_intr_illegal_compstat_fops);
89 if (!d)
90 return -ENOMEM;
91
92 return 0;
93}