summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/vgpu/tsg_vgpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/vgpu/tsg_vgpu.c')
-rw-r--r--drivers/gpu/nvgpu/vgpu/tsg_vgpu.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/vgpu/tsg_vgpu.c b/drivers/gpu/nvgpu/vgpu/tsg_vgpu.c
new file mode 100644
index 00000000..9245693d
--- /dev/null
+++ b/drivers/gpu/nvgpu/vgpu/tsg_vgpu.c
@@ -0,0 +1,85 @@
1/*
2 * Copyright (c) 2016, 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/kernel.h>
18#include <linux/tegra_vgpu.h>
19
20#include "gk20a/gk20a.h"
21#include "gk20a/channel_gk20a.h"
22#include "gk20a/platform_gk20a.h"
23#include "gk20a/tsg_gk20a.h"
24#include "vgpu.h"
25
26static int vgpu_tsg_bind_channel(struct tsg_gk20a *tsg,
27 struct channel_gk20a *ch)
28{
29 struct gk20a_platform *platform = gk20a_get_platform(tsg->g->dev);
30 struct tegra_vgpu_cmd_msg msg = {};
31 struct tegra_vgpu_tsg_bind_unbind_channel_params *p =
32 &msg.params.tsg_bind_unbind_channel;
33 int err;
34
35 gk20a_dbg_fn("");
36
37 err = gk20a_tsg_bind_channel(tsg, ch);
38 if (err)
39 return err;
40
41 msg.cmd = TEGRA_VGPU_CMD_TSG_BIND_CHANNEL;
42 msg.handle = platform->virt_handle;
43 p->tsg_id = tsg->tsgid;
44 p->ch_handle = ch->virt_ctx;
45 err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg));
46 err = err ? err : msg.ret;
47 if (err) {
48 gk20a_err(dev_from_gk20a(tsg->g),
49 "vgpu_tsg_bind_channel failed, ch %d tsgid %d",
50 ch->hw_chid, tsg->tsgid);
51 gk20a_tsg_unbind_channel(ch);
52 }
53
54 return err;
55}
56
57static int vgpu_tsg_unbind_channel(struct channel_gk20a *ch)
58{
59 struct gk20a_platform *platform = gk20a_get_platform(ch->g->dev);
60 struct tegra_vgpu_cmd_msg msg = {};
61 struct tegra_vgpu_tsg_bind_unbind_channel_params *p =
62 &msg.params.tsg_bind_unbind_channel;
63 int err;
64
65 gk20a_dbg_fn("");
66
67 err = gk20a_tsg_unbind_channel(ch);
68 if (err)
69 return err;
70
71 msg.cmd = TEGRA_VGPU_CMD_TSG_UNBIND_CHANNEL;
72 msg.handle = platform->virt_handle;
73 p->ch_handle = ch->virt_ctx;
74 err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg));
75 err = err ? err : msg.ret;
76 WARN_ON(err);
77
78 return err;
79}
80
81void vgpu_init_tsg_ops(struct gpu_ops *gops)
82{
83 gops->fifo.tsg_bind_channel = vgpu_tsg_bind_channel;
84 gops->fifo.tsg_unbind_channel = vgpu_tsg_unbind_channel;
85}