diff options
author | Richard Zhao <rizhao@nvidia.com> | 2018-01-30 02:24:37 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-02-27 17:30:52 -0500 |
commit | 6393eddfa996fba03464f897b85aa5ec79860fed (patch) | |
tree | 557ebe9be93e2b0464118e7d8ec019d9d5dbae5f /drivers/gpu/nvgpu/vgpu/tsg_vgpu.c | |
parent | 7932568b7fe9e16b2b83bc58b2b3686c0d5e52d4 (diff) |
gpu: nvgpu: vgpu: move common files out of linux folder
Most of files have been moved out of linux folder. More code could be
common as halifying going on.
Jira EVLR-2364
Change-Id: Ia9dbdbc82f45ceefe5c788eac7517000cd455d5e
Signed-off-by: Richard Zhao <rizhao@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1649947
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/vgpu/tsg_vgpu.c')
-rw-r--r-- | drivers/gpu/nvgpu/vgpu/tsg_vgpu.c | 160 |
1 files changed, 160 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..a6e493d0 --- /dev/null +++ b/drivers/gpu/nvgpu/vgpu/tsg_vgpu.c | |||
@@ -0,0 +1,160 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #include "gk20a/gk20a.h" | ||
24 | #include "gk20a/channel_gk20a.h" | ||
25 | #include "gk20a/tsg_gk20a.h" | ||
26 | #include "fifo_vgpu.h" | ||
27 | |||
28 | #include <nvgpu/bug.h> | ||
29 | #include <nvgpu/vgpu/tegra_vgpu.h> | ||
30 | #include <nvgpu/vgpu/vgpu.h> | ||
31 | |||
32 | int vgpu_tsg_open(struct tsg_gk20a *tsg) | ||
33 | { | ||
34 | struct tegra_vgpu_cmd_msg msg = {}; | ||
35 | struct tegra_vgpu_tsg_open_rel_params *p = | ||
36 | &msg.params.tsg_open; | ||
37 | int err; | ||
38 | |||
39 | gk20a_dbg_fn(""); | ||
40 | |||
41 | msg.cmd = TEGRA_VGPU_CMD_TSG_OPEN; | ||
42 | msg.handle = vgpu_get_handle(tsg->g); | ||
43 | p->tsg_id = tsg->tsgid; | ||
44 | err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); | ||
45 | err = err ? err : msg.ret; | ||
46 | if (err) { | ||
47 | nvgpu_err(tsg->g, | ||
48 | "vgpu_tsg_open failed, tsgid %d", tsg->tsgid); | ||
49 | } | ||
50 | |||
51 | return err; | ||
52 | } | ||
53 | |||
54 | void vgpu_tsg_release(struct tsg_gk20a *tsg) | ||
55 | { | ||
56 | struct tegra_vgpu_cmd_msg msg = {}; | ||
57 | struct tegra_vgpu_tsg_open_rel_params *p = | ||
58 | &msg.params.tsg_release; | ||
59 | int err; | ||
60 | |||
61 | gk20a_dbg_fn(""); | ||
62 | |||
63 | msg.cmd = TEGRA_VGPU_CMD_TSG_RELEASE; | ||
64 | msg.handle = vgpu_get_handle(tsg->g); | ||
65 | p->tsg_id = tsg->tsgid; | ||
66 | err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); | ||
67 | err = err ? err : msg.ret; | ||
68 | if (err) { | ||
69 | nvgpu_err(tsg->g, | ||
70 | "vgpu_tsg_release failed, tsgid %d", tsg->tsgid); | ||
71 | } | ||
72 | } | ||
73 | |||
74 | int vgpu_enable_tsg(struct tsg_gk20a *tsg) | ||
75 | { | ||
76 | struct gk20a *g = tsg->g; | ||
77 | struct channel_gk20a *ch; | ||
78 | |||
79 | nvgpu_rwsem_down_read(&tsg->ch_list_lock); | ||
80 | nvgpu_list_for_each_entry(ch, &tsg->ch_list, channel_gk20a, ch_entry) | ||
81 | g->ops.fifo.enable_channel(ch); | ||
82 | nvgpu_rwsem_up_read(&tsg->ch_list_lock); | ||
83 | |||
84 | return 0; | ||
85 | } | ||
86 | |||
87 | int vgpu_tsg_bind_channel(struct tsg_gk20a *tsg, | ||
88 | struct channel_gk20a *ch) | ||
89 | { | ||
90 | struct tegra_vgpu_cmd_msg msg = {}; | ||
91 | struct tegra_vgpu_tsg_bind_unbind_channel_params *p = | ||
92 | &msg.params.tsg_bind_unbind_channel; | ||
93 | int err; | ||
94 | |||
95 | gk20a_dbg_fn(""); | ||
96 | |||
97 | err = gk20a_tsg_bind_channel(tsg, ch); | ||
98 | if (err) | ||
99 | return err; | ||
100 | |||
101 | msg.cmd = TEGRA_VGPU_CMD_TSG_BIND_CHANNEL; | ||
102 | msg.handle = vgpu_get_handle(tsg->g); | ||
103 | p->tsg_id = tsg->tsgid; | ||
104 | p->ch_handle = ch->virt_ctx; | ||
105 | err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); | ||
106 | err = err ? err : msg.ret; | ||
107 | if (err) { | ||
108 | nvgpu_err(tsg->g, | ||
109 | "vgpu_tsg_bind_channel failed, ch %d tsgid %d", | ||
110 | ch->chid, tsg->tsgid); | ||
111 | gk20a_tsg_unbind_channel(ch); | ||
112 | } | ||
113 | |||
114 | return err; | ||
115 | } | ||
116 | |||
117 | int vgpu_tsg_unbind_channel(struct channel_gk20a *ch) | ||
118 | { | ||
119 | struct tegra_vgpu_cmd_msg msg = {}; | ||
120 | struct tegra_vgpu_tsg_bind_unbind_channel_params *p = | ||
121 | &msg.params.tsg_bind_unbind_channel; | ||
122 | int err; | ||
123 | |||
124 | gk20a_dbg_fn(""); | ||
125 | |||
126 | err = gk20a_fifo_tsg_unbind_channel(ch); | ||
127 | if (err) | ||
128 | return err; | ||
129 | |||
130 | msg.cmd = TEGRA_VGPU_CMD_TSG_UNBIND_CHANNEL; | ||
131 | msg.handle = vgpu_get_handle(ch->g); | ||
132 | p->ch_handle = ch->virt_ctx; | ||
133 | err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); | ||
134 | err = err ? err : msg.ret; | ||
135 | WARN_ON(err); | ||
136 | |||
137 | return err; | ||
138 | } | ||
139 | |||
140 | int vgpu_tsg_set_timeslice(struct tsg_gk20a *tsg, u32 timeslice) | ||
141 | { | ||
142 | struct tegra_vgpu_cmd_msg msg = {0}; | ||
143 | struct tegra_vgpu_tsg_timeslice_params *p = | ||
144 | &msg.params.tsg_timeslice; | ||
145 | int err; | ||
146 | |||
147 | gk20a_dbg_fn(""); | ||
148 | |||
149 | msg.cmd = TEGRA_VGPU_CMD_TSG_SET_TIMESLICE; | ||
150 | msg.handle = vgpu_get_handle(tsg->g); | ||
151 | p->tsg_id = tsg->tsgid; | ||
152 | p->timeslice_us = timeslice; | ||
153 | err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); | ||
154 | err = err ? err : msg.ret; | ||
155 | WARN_ON(err); | ||
156 | if (!err) | ||
157 | tsg->timeslice_us = timeslice; | ||
158 | |||
159 | return err; | ||
160 | } | ||