summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/linux/vgpu/dbg_vgpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/vgpu/dbg_vgpu.c')
-rw-r--r--drivers/gpu/nvgpu/common/linux/vgpu/dbg_vgpu.c209
1 files changed, 0 insertions, 209 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/vgpu/dbg_vgpu.c b/drivers/gpu/nvgpu/common/linux/vgpu/dbg_vgpu.c
deleted file mode 100644
index 11ebe84b..00000000
--- a/drivers/gpu/nvgpu/common/linux/vgpu/dbg_vgpu.c
+++ /dev/null
@@ -1,209 +0,0 @@
1/*
2 * Copyright (c) 2015-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 <nvgpu/vgpu/vgpu_ivc.h>
18#include <nvgpu/vgpu/tegra_vgpu.h>
19
20#include "gk20a/gk20a.h"
21#include "gk20a/channel_gk20a.h"
22#include "gk20a/dbg_gpu_gk20a.h"
23#include "gk20a/regops_gk20a.h"
24#include "vgpu.h"
25#include "dbg_vgpu.h"
26
27#include <nvgpu/bug.h>
28
29int vgpu_exec_regops(struct dbg_session_gk20a *dbg_s,
30 struct nvgpu_dbg_reg_op *ops,
31 u64 num_ops)
32{
33 struct channel_gk20a *ch;
34 struct tegra_vgpu_cmd_msg msg;
35 struct tegra_vgpu_reg_ops_params *p = &msg.params.reg_ops;
36 void *oob;
37 size_t oob_size, ops_size;
38 void *handle = NULL;
39 int err = 0;
40
41 gk20a_dbg_fn("");
42 BUG_ON(sizeof(*ops) != sizeof(struct tegra_vgpu_reg_op));
43
44 handle = vgpu_ivc_oob_get_ptr(vgpu_ivc_get_server_vmid(),
45 TEGRA_VGPU_QUEUE_CMD,
46 &oob, &oob_size);
47 if (!handle)
48 return -EINVAL;
49
50 ops_size = sizeof(*ops) * num_ops;
51 if (oob_size < ops_size) {
52 err = -ENOMEM;
53 goto fail;
54 }
55
56 memcpy(oob, ops, ops_size);
57
58 msg.cmd = TEGRA_VGPU_CMD_REG_OPS;
59 msg.handle = vgpu_get_handle(dbg_s->g);
60 ch = nvgpu_dbg_gpu_get_session_channel(dbg_s);
61 p->handle = ch ? ch->virt_ctx : 0;
62 p->num_ops = num_ops;
63 p->is_profiler = dbg_s->is_profiler;
64 err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg));
65 err = err ? err : msg.ret;
66 if (!err)
67 memcpy(ops, oob, ops_size);
68
69fail:
70 vgpu_ivc_oob_put_ptr(handle);
71 return err;
72}
73
74int vgpu_dbg_set_powergate(struct dbg_session_gk20a *dbg_s, bool disable_powergate)
75{
76 struct tegra_vgpu_cmd_msg msg;
77 struct tegra_vgpu_set_powergate_params *p = &msg.params.set_powergate;
78 int err = 0;
79 u32 mode;
80
81 gk20a_dbg_fn("");
82
83 /* Just return if requested mode is the same as the session's mode */
84 if (disable_powergate) {
85 if (dbg_s->is_pg_disabled)
86 return 0;
87 dbg_s->is_pg_disabled = true;
88 mode = TEGRA_VGPU_POWERGATE_MODE_DISABLE;
89 } else {
90 if (!dbg_s->is_pg_disabled)
91 return 0;
92 dbg_s->is_pg_disabled = false;
93 mode = TEGRA_VGPU_POWERGATE_MODE_ENABLE;
94 }
95
96 msg.cmd = TEGRA_VGPU_CMD_SET_POWERGATE;
97 msg.handle = vgpu_get_handle(dbg_s->g);
98 p->mode = mode;
99 err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg));
100 err = err ? err : msg.ret;
101 return err;
102}
103
104static int vgpu_sendrecv_prof_cmd(struct dbg_session_gk20a *dbg_s, u32 mode)
105{
106 struct tegra_vgpu_cmd_msg msg;
107 struct tegra_vgpu_prof_mgt_params *p = &msg.params.prof_management;
108 int err = 0;
109
110 msg.cmd = TEGRA_VGPU_CMD_PROF_MGT;
111 msg.handle = vgpu_get_handle(dbg_s->g);
112
113 p->mode = mode;
114
115 err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg));
116 err = err ? err : msg.ret;
117 return err;
118}
119
120bool vgpu_check_and_set_global_reservation(
121 struct dbg_session_gk20a *dbg_s,
122 struct dbg_profiler_object_data *prof_obj)
123{
124 struct gk20a *g = dbg_s->g;
125
126 if (g->profiler_reservation_count > 0)
127 return false;
128
129 /* Check that another guest OS doesn't already have a reservation */
130 if (!vgpu_sendrecv_prof_cmd(dbg_s, TEGRA_VGPU_PROF_GET_GLOBAL)) {
131 g->global_profiler_reservation_held = true;
132 g->profiler_reservation_count = 1;
133 dbg_s->has_profiler_reservation = true;
134 prof_obj->has_reservation = true;
135 return true;
136 }
137 return false;
138}
139
140bool vgpu_check_and_set_context_reservation(
141 struct dbg_session_gk20a *dbg_s,
142 struct dbg_profiler_object_data *prof_obj)
143{
144 struct gk20a *g = dbg_s->g;
145
146 /* Assumes that we've already checked that no global reservation
147 * is in effect for this guest.
148 *
149 * If our reservation count is non-zero, then no other guest has the
150 * global reservation; if it is zero, need to check with RM server.
151 *
152 */
153 if ((g->profiler_reservation_count != 0) ||
154 !vgpu_sendrecv_prof_cmd(dbg_s, TEGRA_VGPU_PROF_GET_CONTEXT)) {
155 g->profiler_reservation_count++;
156 dbg_s->has_profiler_reservation = true;
157 prof_obj->has_reservation = true;
158 return true;
159 }
160 return false;
161}
162
163void vgpu_release_profiler_reservation(
164 struct dbg_session_gk20a *dbg_s,
165 struct dbg_profiler_object_data *prof_obj)
166{
167 struct gk20a *g = dbg_s->g;
168
169 dbg_s->has_profiler_reservation = false;
170 prof_obj->has_reservation = false;
171 if (prof_obj->ch == NULL)
172 g->global_profiler_reservation_held = false;
173
174 /* If new reservation count is zero, notify server */
175 g->profiler_reservation_count--;
176 if (g->profiler_reservation_count == 0)
177 vgpu_sendrecv_prof_cmd(dbg_s, TEGRA_VGPU_PROF_RELEASE);
178}
179
180static int vgpu_sendrecv_perfbuf_cmd(struct gk20a *g, u64 offset, u32 size)
181{
182 struct mm_gk20a *mm = &g->mm;
183 struct vm_gk20a *vm = mm->perfbuf.vm;
184 struct tegra_vgpu_cmd_msg msg;
185 struct tegra_vgpu_perfbuf_mgt_params *p =
186 &msg.params.perfbuf_management;
187 int err;
188
189 msg.cmd = TEGRA_VGPU_CMD_PERFBUF_MGT;
190 msg.handle = vgpu_get_handle(g);
191
192 p->vm_handle = vm->handle;
193 p->offset = offset;
194 p->size = size;
195
196 err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg));
197 err = err ? err : msg.ret;
198 return err;
199}
200
201int vgpu_perfbuffer_enable(struct gk20a *g, u64 offset, u32 size)
202{
203 return vgpu_sendrecv_perfbuf_cmd(g, offset, size);
204}
205
206int vgpu_perfbuffer_disable(struct gk20a *g)
207{
208 return vgpu_sendrecv_perfbuf_cmd(g, 0, 0);
209}