summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/os
diff options
context:
space:
mode:
authorNitin Kumbhar <nkumbhar@nvidia.com>2018-09-04 06:49:47 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-09-09 20:22:24 -0400
commite93a4ca50b6b24d3db1f8fdc0e5030fecb5ea8d2 (patch)
tree204853d4398aaab0a5d69bbc4426e7f78d1753a7 /drivers/gpu/nvgpu/os
parentb2ba12ed55e9b7079b4216d091003ad6f49a4433 (diff)
gpu: nvgpu: move fecs trace debugfs to linux
Add fecs trace debugfs initialization as an os op. The debugfs nodes are set up for gpu versions which call gk20a_fecs_trace_init(). JIRA NVGPU-602 Change-Id: I606ec31acbf04f633500be4c342db32f3f537794 Signed-off-by: Nitin Kumbhar <nkumbhar@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1812449 Reviewed-by: Deepak Nibade <dnibade@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: svc-misra-checker <svc-misra-checker@nvidia.com> Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/os')
-rw-r--r--drivers/gpu/nvgpu/os/linux/debug_fecs_trace.c154
-rw-r--r--drivers/gpu/nvgpu/os/linux/debug_fecs_trace.h30
-rw-r--r--drivers/gpu/nvgpu/os/linux/module.c8
-rw-r--r--drivers/gpu/nvgpu/os/linux/os_linux.h4
-rw-r--r--drivers/gpu/nvgpu/os/linux/os_ops.c4
-rw-r--r--drivers/gpu/nvgpu/os/linux/os_ops_gp106.c5
-rw-r--r--drivers/gpu/nvgpu/os/linux/os_ops_gp10b.c5
-rw-r--r--drivers/gpu/nvgpu/os/linux/os_ops_gv100.c5
-rw-r--r--drivers/gpu/nvgpu/os/linux/os_ops_gv11b.c30
-rw-r--r--drivers/gpu/nvgpu/os/linux/os_ops_gv11b.h24
10 files changed, 269 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/os/linux/debug_fecs_trace.c b/drivers/gpu/nvgpu/os/linux/debug_fecs_trace.c
new file mode 100644
index 00000000..9e72d2ce
--- /dev/null
+++ b/drivers/gpu/nvgpu/os/linux/debug_fecs_trace.c
@@ -0,0 +1,154 @@
1/*
2 * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <linux/debugfs.h>
18
19#include <nvgpu/fecs_trace.h>
20
21#include "os_linux.h"
22
23/*
24 * The sequence iterator functions. We simply use the count of the
25 * next line as our internal position.
26 */
27static void *gk20a_fecs_trace_debugfs_ring_seq_start(
28 struct seq_file *s, loff_t *pos)
29{
30 if (*pos >= GK20A_FECS_TRACE_NUM_RECORDS)
31 return NULL;
32
33 return pos;
34}
35
36static void *gk20a_fecs_trace_debugfs_ring_seq_next(
37 struct seq_file *s, void *v, loff_t *pos)
38{
39 ++(*pos);
40 if (*pos >= GK20A_FECS_TRACE_NUM_RECORDS)
41 return NULL;
42 return pos;
43}
44
45static void gk20a_fecs_trace_debugfs_ring_seq_stop(
46 struct seq_file *s, void *v)
47{
48}
49
50static int gk20a_fecs_trace_debugfs_ring_seq_show(
51 struct seq_file *s, void *v)
52{
53 loff_t *pos = (loff_t *) v;
54 struct gk20a *g = *(struct gk20a **)s->private;
55 struct gk20a_fecs_trace_record *r =
56 gk20a_fecs_trace_get_record(g, *pos);
57 int i;
58 const u32 invalid_tag = gk20a_fecs_trace_record_ts_tag_invalid_ts_v();
59 u32 tag;
60 u64 timestamp;
61
62 seq_printf(s, "record #%lld (%p)\n", *pos, r);
63 seq_printf(s, "\tmagic_lo=%08x\n", r->magic_lo);
64 seq_printf(s, "\tmagic_hi=%08x\n", r->magic_hi);
65 if (gk20a_fecs_trace_is_valid_record(r)) {
66 seq_printf(s, "\tcontext_ptr=%08x\n", r->context_ptr);
67 seq_printf(s, "\tcontext_id=%08x\n", r->context_id);
68 seq_printf(s, "\tnew_context_ptr=%08x\n", r->new_context_ptr);
69 seq_printf(s, "\tnew_context_id=%08x\n", r->new_context_id);
70 for (i = 0; i < gk20a_fecs_trace_num_ts(); i++) {
71 tag = gk20a_fecs_trace_record_ts_tag_v(r->ts[i]);
72 if (tag == invalid_tag)
73 continue;
74 timestamp = gk20a_fecs_trace_record_ts_timestamp_v(r->ts[i]);
75 timestamp <<= GK20A_FECS_TRACE_PTIMER_SHIFT;
76 seq_printf(s, "\ttag=%02x timestamp=%012llx\n", tag, timestamp);
77 }
78 }
79 return 0;
80}
81
82/*
83 * Tie them all together into a set of seq_operations.
84 */
85static const struct seq_operations gk20a_fecs_trace_debugfs_ring_seq_ops = {
86 .start = gk20a_fecs_trace_debugfs_ring_seq_start,
87 .next = gk20a_fecs_trace_debugfs_ring_seq_next,
88 .stop = gk20a_fecs_trace_debugfs_ring_seq_stop,
89 .show = gk20a_fecs_trace_debugfs_ring_seq_show
90};
91
92/*
93 * Time to set up the file operations for our /proc file. In this case,
94 * all we need is an open function which sets up the sequence ops.
95 */
96
97static int gk20a_ctxsw_debugfs_ring_open(struct inode *inode,
98 struct file *file)
99{
100 struct gk20a **p;
101
102 if (!capable(CAP_SYS_ADMIN))
103 return -EPERM;
104
105 p = __seq_open_private(file, &gk20a_fecs_trace_debugfs_ring_seq_ops,
106 sizeof(struct gk20a *));
107 if (!p)
108 return -ENOMEM;
109
110 *p = (struct gk20a *)inode->i_private;
111 return 0;
112};
113
114/*
115 * The file operations structure contains our open function along with
116 * set of the canned seq_ ops.
117 */
118static const struct file_operations gk20a_fecs_trace_debugfs_ring_fops = {
119 .owner = THIS_MODULE,
120 .open = gk20a_ctxsw_debugfs_ring_open,
121 .read = seq_read,
122 .llseek = seq_lseek,
123 .release = seq_release_private
124};
125
126static int gk20a_fecs_trace_debugfs_read(void *arg, u64 *val)
127{
128 *val = gk20a_fecs_trace_get_read_index((struct gk20a *)arg);
129 return 0;
130}
131DEFINE_SIMPLE_ATTRIBUTE(gk20a_fecs_trace_debugfs_read_fops,
132 gk20a_fecs_trace_debugfs_read, NULL, "%llu\n");
133
134static int gk20a_fecs_trace_debugfs_write(void *arg, u64 *val)
135{
136 *val = gk20a_fecs_trace_get_write_index((struct gk20a *)arg);
137 return 0;
138}
139DEFINE_SIMPLE_ATTRIBUTE(gk20a_fecs_trace_debugfs_write_fops,
140 gk20a_fecs_trace_debugfs_write, NULL, "%llu\n");
141
142int nvgpu_fecs_trace_init_debugfs(struct gk20a *g)
143{
144 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
145
146 debugfs_create_file("ctxsw_trace_read", 0600, l->debugfs, g,
147 &gk20a_fecs_trace_debugfs_read_fops);
148 debugfs_create_file("ctxsw_trace_write", 0600, l->debugfs, g,
149 &gk20a_fecs_trace_debugfs_write_fops);
150 debugfs_create_file("ctxsw_trace_ring", 0600, l->debugfs, g,
151 &gk20a_fecs_trace_debugfs_ring_fops);
152
153 return 0;
154}
diff --git a/drivers/gpu/nvgpu/os/linux/debug_fecs_trace.h b/drivers/gpu/nvgpu/os/linux/debug_fecs_trace.h
new file mode 100644
index 00000000..a545f2db
--- /dev/null
+++ b/drivers/gpu/nvgpu/os/linux/debug_fecs_trace.h
@@ -0,0 +1,30 @@
1/*
2 * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef LINUX_DEBUG_FECS_TRACE_H
18#define LINUX_DEBUG_FECS_TRACE_H
19
20struct gk20a;
21
22#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_GK20A_CTXSW_TRACE)
23int nvgpu_fecs_trace_init_debugfs(struct gk20a *g);
24#else
25int nvgpu_fecs_trace_init_debugfs(struct gk20a *g)
26{
27 return 0;
28}
29#endif
30#endif
diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c
index 85439b88..ff4d9a4c 100644
--- a/drivers/gpu/nvgpu/os/linux/module.c
+++ b/drivers/gpu/nvgpu/os/linux/module.c
@@ -216,6 +216,14 @@ int nvgpu_finalize_poweron_linux(struct nvgpu_os_linux *l)
216 } 216 }
217 } 217 }
218 218
219 if (l->ops.fecs_trace.init_debugfs) {
220 err = l->ops.fecs_trace.init_debugfs(g);
221 if (err) {
222 nvgpu_err(g, "failed to init linux fecs trace debugfs");
223 return err;
224 }
225 }
226
219 err = nvgpu_pmgr_init_debugfs_linux(l); 227 err = nvgpu_pmgr_init_debugfs_linux(l);
220 if (err) { 228 if (err) {
221 nvgpu_err(g, "failed to init linux pmgr debugfs"); 229 nvgpu_err(g, "failed to init linux pmgr debugfs");
diff --git a/drivers/gpu/nvgpu/os/linux/os_linux.h b/drivers/gpu/nvgpu/os/linux/os_linux.h
index ff871fe5..a9a9ebb6 100644
--- a/drivers/gpu/nvgpu/os/linux/os_linux.h
+++ b/drivers/gpu/nvgpu/os/linux/os_linux.h
@@ -46,6 +46,10 @@ struct nvgpu_os_linux_ops {
46 struct { 46 struct {
47 int (*init_debugfs)(struct gk20a *g); 47 int (*init_debugfs)(struct gk20a *g);
48 } therm; 48 } therm;
49
50 struct {
51 int (*init_debugfs)(struct gk20a *g);
52 } fecs_trace;
49}; 53};
50 54
51struct nvgpu_os_linux { 55struct nvgpu_os_linux {
diff --git a/drivers/gpu/nvgpu/os/linux/os_ops.c b/drivers/gpu/nvgpu/os/linux/os_ops.c
index 5c2eb25c..f1ab4b15 100644
--- a/drivers/gpu/nvgpu/os/linux/os_ops.c
+++ b/drivers/gpu/nvgpu/os/linux/os_ops.c
@@ -19,6 +19,7 @@
19#include "os_ops_gm20b.h" 19#include "os_ops_gm20b.h"
20#include "os_ops_gp10b.h" 20#include "os_ops_gp10b.h"
21#include "os_ops_gp106.h" 21#include "os_ops_gp106.h"
22#include "os_ops_gv11b.h"
22#include "os_ops_gv100.h" 23#include "os_ops_gv100.h"
23 24
24#if defined(CONFIG_TEGRA_GPU_NEXT) 25#if defined(CONFIG_TEGRA_GPU_NEXT)
@@ -44,6 +45,9 @@ int nvgpu_init_os_linux_ops(struct nvgpu_os_linux *l)
44 case NVGPU_GPUID_GV100: 45 case NVGPU_GPUID_GV100:
45 nvgpu_gv100_init_os_ops(l); 46 nvgpu_gv100_init_os_ops(l);
46 break; 47 break;
48 case NVGPU_GPUID_GV11B:
49 nvgpu_gv11b_init_os_ops(l);
50 break;
47#if defined(CONFIG_TEGRA_GPU_NEXT) 51#if defined(CONFIG_TEGRA_GPU_NEXT)
48 case NVGPU_GPUID_NEXT: 52 case NVGPU_GPUID_NEXT:
49 NVGPU_NEXT_INIT_OS_OPS(l); 53 NVGPU_NEXT_INIT_OS_OPS(l);
diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_gp106.c b/drivers/gpu/nvgpu/os/linux/os_ops_gp106.c
index 662f4551..14f1b004 100644
--- a/drivers/gpu/nvgpu/os/linux/os_ops_gp106.c
+++ b/drivers/gpu/nvgpu/os/linux/os_ops_gp106.c
@@ -18,6 +18,7 @@
18 18
19#include "debug_clk_gp106.h" 19#include "debug_clk_gp106.h"
20#include "debug_therm_gp106.h" 20#include "debug_therm_gp106.h"
21#include "debug_fecs_trace.h"
21 22
22static struct nvgpu_os_linux_ops gp106_os_linux_ops = { 23static struct nvgpu_os_linux_ops gp106_os_linux_ops = {
23 .clk = { 24 .clk = {
@@ -26,10 +27,14 @@ static struct nvgpu_os_linux_ops gp106_os_linux_ops = {
26 .therm = { 27 .therm = {
27 .init_debugfs = gp106_therm_init_debugfs, 28 .init_debugfs = gp106_therm_init_debugfs,
28 }, 29 },
30 .fecs_trace = {
31 .init_debugfs = nvgpu_fecs_trace_init_debugfs,
32 },
29}; 33};
30 34
31void nvgpu_gp106_init_os_ops(struct nvgpu_os_linux *l) 35void nvgpu_gp106_init_os_ops(struct nvgpu_os_linux *l)
32{ 36{
33 l->ops.clk = gp106_os_linux_ops.clk; 37 l->ops.clk = gp106_os_linux_ops.clk;
34 l->ops.therm = gp106_os_linux_ops.therm; 38 l->ops.therm = gp106_os_linux_ops.therm;
39 l->ops.fecs_trace = gp106_os_linux_ops.fecs_trace;
35} 40}
diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_gp10b.c b/drivers/gpu/nvgpu/os/linux/os_ops_gp10b.c
index 984dcdc0..e2891f73 100644
--- a/drivers/gpu/nvgpu/os/linux/os_ops_gp10b.c
+++ b/drivers/gpu/nvgpu/os/linux/os_ops_gp10b.c
@@ -17,6 +17,7 @@
17#include "os_linux.h" 17#include "os_linux.h"
18 18
19#include "cde_gp10b.h" 19#include "cde_gp10b.h"
20#include "debug_fecs_trace.h"
20 21
21static struct nvgpu_os_linux_ops gp10b_os_linux_ops = { 22static struct nvgpu_os_linux_ops gp10b_os_linux_ops = {
22#ifdef CONFIG_NVGPU_SUPPORT_CDE 23#ifdef CONFIG_NVGPU_SUPPORT_CDE
@@ -26,6 +27,9 @@ static struct nvgpu_os_linux_ops gp10b_os_linux_ops = {
26 .populate_scatter_buffer = gp10b_populate_scatter_buffer, 27 .populate_scatter_buffer = gp10b_populate_scatter_buffer,
27 }, 28 },
28#endif 29#endif
30 .fecs_trace = {
31 .init_debugfs = nvgpu_fecs_trace_init_debugfs,
32 },
29}; 33};
30 34
31void nvgpu_gp10b_init_os_ops(struct nvgpu_os_linux *l) 35void nvgpu_gp10b_init_os_ops(struct nvgpu_os_linux *l)
@@ -33,4 +37,5 @@ void nvgpu_gp10b_init_os_ops(struct nvgpu_os_linux *l)
33#ifdef CONFIG_NVGPU_SUPPORT_CDE 37#ifdef CONFIG_NVGPU_SUPPORT_CDE
34 l->ops.cde = gp10b_os_linux_ops.cde; 38 l->ops.cde = gp10b_os_linux_ops.cde;
35#endif 39#endif
40 l->ops.fecs_trace = gp10b_os_linux_ops.fecs_trace;
36} 41}
diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c b/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c
index 7a5174a4..f5c5a604 100644
--- a/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c
+++ b/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c
@@ -18,6 +18,7 @@
18 18
19#include "debug_clk_gp106.h" 19#include "debug_clk_gp106.h"
20#include "debug_therm_gp106.h" 20#include "debug_therm_gp106.h"
21#include "debug_fecs_trace.h"
21 22
22static struct nvgpu_os_linux_ops gv100_os_linux_ops = { 23static struct nvgpu_os_linux_ops gv100_os_linux_ops = {
23 .clk = { 24 .clk = {
@@ -26,10 +27,14 @@ static struct nvgpu_os_linux_ops gv100_os_linux_ops = {
26 .therm = { 27 .therm = {
27 .init_debugfs = gp106_therm_init_debugfs, 28 .init_debugfs = gp106_therm_init_debugfs,
28 }, 29 },
30 .fecs_trace = {
31 .init_debugfs = nvgpu_fecs_trace_init_debugfs,
32 },
29}; 33};
30 34
31void nvgpu_gv100_init_os_ops(struct nvgpu_os_linux *l) 35void nvgpu_gv100_init_os_ops(struct nvgpu_os_linux *l)
32{ 36{
33 l->ops.clk = gv100_os_linux_ops.clk; 37 l->ops.clk = gv100_os_linux_ops.clk;
34 l->ops.therm = gv100_os_linux_ops.therm; 38 l->ops.therm = gv100_os_linux_ops.therm;
39 l->ops.fecs_trace = gv100_os_linux_ops.fecs_trace;
35} 40}
diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_gv11b.c b/drivers/gpu/nvgpu/os/linux/os_ops_gv11b.c
new file mode 100644
index 00000000..a82ad0ab
--- /dev/null
+++ b/drivers/gpu/nvgpu/os/linux/os_ops_gv11b.c
@@ -0,0 +1,30 @@
1/*
2 * Copyright (c) 2018, NVIDIA Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "os_linux.h"
18
19#include "debug_fecs_trace.h"
20
21static struct nvgpu_os_linux_ops gv11b_os_linux_ops = {
22 .fecs_trace = {
23 .init_debugfs = nvgpu_fecs_trace_init_debugfs,
24 },
25};
26
27void nvgpu_gv11b_init_os_ops(struct nvgpu_os_linux *l)
28{
29 l->ops.fecs_trace = gv11b_os_linux_ops.fecs_trace;
30}
diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_gv11b.h b/drivers/gpu/nvgpu/os/linux/os_ops_gv11b.h
new file mode 100644
index 00000000..eef6c4ac
--- /dev/null
+++ b/drivers/gpu/nvgpu/os/linux/os_ops_gv11b.h
@@ -0,0 +1,24 @@
1/*
2 * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef LINUX_OS_OPS_GV11B_H
18#define LINUX_OS_OPS_GV11B_H
19
20struct nvgpu_os_linux;
21
22void nvgpu_gv11b_init_os_ops(struct nvgpu_os_linux *l);
23
24#endif