summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/vgpu/dbg_vgpu.c
diff options
context:
space:
mode:
authorPeter Daifuku <pdaifuku@nvidia.com>2017-03-17 14:36:19 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-03-24 12:08:17 -0400
commitfd02ab4d540ef473df1fe189653cc521876663d6 (patch)
tree1c61ea5b63900808cf79903e72a0bf462814b077 /drivers/gpu/nvgpu/vgpu/dbg_vgpu.c
parenta9fb2a4824a48f4ff193a1a54d1143ac0395aa95 (diff)
gpu: nvgpu: vgpu: profiler reservation support
Support for hwpm reservations in the virtual case: - Add session ops for checking and setting global and context reservations, and releasing reservations - in the native case, these just update reservation counts and flags - in the vgpu case, when the reservation count is 0, check with the RM server that a reservation is possible: for global reservations, no other guest can have a reservation; for context reservations, no other guest can have a global reservation - in the vgpu case, when the reservation count is decremented to 0, notify the RM server that the guest no longer has any reservations Bug 1775465 JIRA VFND-3428 Change-Id: Idf115b730e465e35d0745c96a8f8ab6b645c7cae Signed-off-by: Peter Daifuku <pdaifuku@nvidia.com> Reviewed-on: http://git-master/r/1323375 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/vgpu/dbg_vgpu.c')
-rw-r--r--drivers/gpu/nvgpu/vgpu/dbg_vgpu.c84
1 files changed, 83 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/vgpu/dbg_vgpu.c b/drivers/gpu/nvgpu/vgpu/dbg_vgpu.c
index 609b497a..a2e57ed5 100644
--- a/drivers/gpu/nvgpu/vgpu/dbg_vgpu.c
+++ b/drivers/gpu/nvgpu/vgpu/dbg_vgpu.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved. 2 * Copyright (c) 2015-2017, NVIDIA CORPORATION. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 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, 5 * under the terms and conditions of the GNU General Public License,
@@ -100,8 +100,90 @@ static int vgpu_dbg_set_powergate(struct dbg_session_gk20a *dbg_s, __u32 mode)
100 return err; 100 return err;
101} 101}
102 102
103static int vgpu_sendrecv_prof_cmd(struct dbg_session_gk20a *dbg_s, u32 mode)
104{
105 struct tegra_vgpu_cmd_msg msg;
106 struct tegra_vgpu_prof_mgt_params *p = &msg.params.prof_management;
107 int err = 0;
108
109 msg.cmd = TEGRA_VGPU_CMD_PROF_MGT;
110 msg.handle = vgpu_get_handle(dbg_s->g);
111
112 p->mode = mode;
113
114 err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg));
115 err = err ? err : msg.ret;
116 return err;
117}
118
119static bool vgpu_check_and_set_global_reservation(
120 struct dbg_session_gk20a *dbg_s,
121 struct dbg_profiler_object_data *prof_obj)
122{
123 struct gk20a *g = dbg_s->g;
124
125 if (g->profiler_reservation_count > 0)
126 return false;
127
128 /* Check that another guest OS doesn't already have a reservation */
129 if (!vgpu_sendrecv_prof_cmd(dbg_s, TEGRA_VGPU_PROF_GET_GLOBAL)) {
130 g->global_profiler_reservation_held = true;
131 g->profiler_reservation_count = 1;
132 dbg_s->has_profiler_reservation = true;
133 prof_obj->has_reservation = true;
134 return true;
135 }
136 return false;
137}
138
139static bool vgpu_check_and_set_context_reservation(
140 struct dbg_session_gk20a *dbg_s,
141 struct dbg_profiler_object_data *prof_obj)
142{
143 struct gk20a *g = dbg_s->g;
144
145 /* Assumes that we've already checked that no global reservation
146 * is in effect for this guest.
147 *
148 * If our reservation count is non-zero, then no other guest has the
149 * global reservation; if it is zero, need to check with RM server.
150 *
151 */
152 if ((g->profiler_reservation_count != 0) ||
153 !vgpu_sendrecv_prof_cmd(dbg_s, TEGRA_VGPU_PROF_GET_CONTEXT)) {
154 g->profiler_reservation_count++;
155 dbg_s->has_profiler_reservation = true;
156 prof_obj->has_reservation = true;
157 return true;
158 }
159 return false;
160}
161
162static void vgpu_release_profiler_reservation(
163 struct dbg_session_gk20a *dbg_s,
164 struct dbg_profiler_object_data *prof_obj)
165{
166 struct gk20a *g = dbg_s->g;
167
168 dbg_s->has_profiler_reservation = false;
169 prof_obj->has_reservation = false;
170 if (prof_obj->ch == NULL)
171 g->global_profiler_reservation_held = false;
172
173 /* If new reservation count is zero, notify server */
174 g->profiler_reservation_count--;
175 if (g->profiler_reservation_count == 0)
176 vgpu_sendrecv_prof_cmd(dbg_s, TEGRA_VGPU_PROF_RELEASE);
177}
178
103void vgpu_init_dbg_session_ops(struct gpu_ops *gops) 179void vgpu_init_dbg_session_ops(struct gpu_ops *gops)
104{ 180{
105 gops->dbg_session_ops.exec_reg_ops = vgpu_exec_regops; 181 gops->dbg_session_ops.exec_reg_ops = vgpu_exec_regops;
106 gops->dbg_session_ops.dbg_set_powergate = vgpu_dbg_set_powergate; 182 gops->dbg_session_ops.dbg_set_powergate = vgpu_dbg_set_powergate;
183 gops->dbg_session_ops.check_and_set_global_reservation =
184 vgpu_check_and_set_global_reservation;
185 gops->dbg_session_ops.check_and_set_context_reservation =
186 vgpu_check_and_set_context_reservation;
187 gops->dbg_session_ops.release_profiler_reservation =
188 vgpu_release_profiler_reservation;
107} 189}