diff options
author | Terje Bergstrom <tbergstrom@nvidia.com> | 2018-04-18 15:59:00 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-06-15 20:47:31 -0400 |
commit | 2a2c16af5f9f1ccfc93a13e820d5381e5c881e92 (patch) | |
tree | 2e5d7b042270a649978e5bb540857012c85fb5b5 /drivers/gpu/nvgpu/common/linux/nvhost.c | |
parent | 98d996f4ffb0137d119b5849cae46d7b7e5693e1 (diff) |
gpu: nvgpu: Move Linux files away from common
Move all Linux source code files to drivers/gpu/nvgpu/os/linux from
drivers/gpu/nvgpu/common/linux. This changes the meaning of common
to be OS independent.
JIRA NVGPU-598
JIRA NVGPU-601
Change-Id: Ib7f2a43d3688bb0d0b7dcc48469a6783fd988ce9
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1747714
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/nvhost.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/nvhost.c | 294 |
1 files changed, 0 insertions, 294 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/nvhost.c b/drivers/gpu/nvgpu/common/linux/nvhost.c deleted file mode 100644 index 6ab60248..00000000 --- a/drivers/gpu/nvgpu/common/linux/nvhost.c +++ /dev/null | |||
@@ -1,294 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017-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/nvhost.h> | ||
18 | #include <linux/nvhost_t194.h> | ||
19 | #include <linux/nvhost_ioctl.h> | ||
20 | #include <linux/of_platform.h> | ||
21 | |||
22 | #include <nvgpu/nvhost.h> | ||
23 | |||
24 | #include "nvhost_priv.h" | ||
25 | |||
26 | #include "gk20a/gk20a.h" | ||
27 | #include "os_linux.h" | ||
28 | #include "module.h" | ||
29 | |||
30 | int nvgpu_get_nvhost_dev(struct gk20a *g) | ||
31 | { | ||
32 | struct device_node *np = nvgpu_get_node(g); | ||
33 | struct platform_device *host1x_pdev = NULL; | ||
34 | const __be32 *host1x_ptr; | ||
35 | |||
36 | host1x_ptr = of_get_property(np, "nvidia,host1x", NULL); | ||
37 | if (host1x_ptr) { | ||
38 | struct device_node *host1x_node = | ||
39 | of_find_node_by_phandle(be32_to_cpup(host1x_ptr)); | ||
40 | |||
41 | host1x_pdev = of_find_device_by_node(host1x_node); | ||
42 | if (!host1x_pdev) { | ||
43 | nvgpu_warn(g, "host1x device not available"); | ||
44 | return -EPROBE_DEFER; | ||
45 | } | ||
46 | |||
47 | } else { | ||
48 | if (g->has_syncpoints) { | ||
49 | nvgpu_warn(g, "host1x reference not found. assuming no syncpoints support"); | ||
50 | g->has_syncpoints = false; | ||
51 | } | ||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | g->nvhost_dev = nvgpu_kzalloc(g, sizeof(struct nvgpu_nvhost_dev)); | ||
56 | if (!g->nvhost_dev) | ||
57 | return -ENOMEM; | ||
58 | |||
59 | g->nvhost_dev->host1x_pdev = host1x_pdev; | ||
60 | |||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | void nvgpu_free_nvhost_dev(struct gk20a *g) | ||
65 | { | ||
66 | nvgpu_kfree(g, g->nvhost_dev); | ||
67 | } | ||
68 | |||
69 | int nvgpu_nvhost_module_busy_ext( | ||
70 | struct nvgpu_nvhost_dev *nvhost_dev) | ||
71 | { | ||
72 | return nvhost_module_busy_ext(nvhost_dev->host1x_pdev); | ||
73 | } | ||
74 | |||
75 | void nvgpu_nvhost_module_idle_ext( | ||
76 | struct nvgpu_nvhost_dev *nvhost_dev) | ||
77 | { | ||
78 | nvhost_module_idle_ext(nvhost_dev->host1x_pdev); | ||
79 | } | ||
80 | |||
81 | void nvgpu_nvhost_debug_dump_device( | ||
82 | struct nvgpu_nvhost_dev *nvhost_dev) | ||
83 | { | ||
84 | nvhost_debug_dump_device(nvhost_dev->host1x_pdev); | ||
85 | } | ||
86 | |||
87 | const char *nvgpu_nvhost_syncpt_get_name( | ||
88 | struct nvgpu_nvhost_dev *nvhost_dev, int id) | ||
89 | { | ||
90 | return nvhost_syncpt_get_name(nvhost_dev->host1x_pdev, id); | ||
91 | } | ||
92 | |||
93 | bool nvgpu_nvhost_syncpt_is_valid_pt_ext( | ||
94 | struct nvgpu_nvhost_dev *nvhost_dev, u32 id) | ||
95 | { | ||
96 | return nvhost_syncpt_is_valid_pt_ext(nvhost_dev->host1x_pdev, id); | ||
97 | } | ||
98 | |||
99 | int nvgpu_nvhost_syncpt_is_expired_ext( | ||
100 | struct nvgpu_nvhost_dev *nvhost_dev, u32 id, u32 thresh) | ||
101 | { | ||
102 | return nvhost_syncpt_is_expired_ext(nvhost_dev->host1x_pdev, | ||
103 | id, thresh); | ||
104 | } | ||
105 | |||
106 | u32 nvgpu_nvhost_syncpt_incr_max_ext( | ||
107 | struct nvgpu_nvhost_dev *nvhost_dev, u32 id, u32 incrs) | ||
108 | { | ||
109 | return nvhost_syncpt_incr_max_ext(nvhost_dev->host1x_pdev, id, incrs); | ||
110 | } | ||
111 | |||
112 | int nvgpu_nvhost_intr_register_notifier( | ||
113 | struct nvgpu_nvhost_dev *nvhost_dev, u32 id, u32 thresh, | ||
114 | void (*callback)(void *, int), void *private_data) | ||
115 | { | ||
116 | return nvhost_intr_register_notifier(nvhost_dev->host1x_pdev, | ||
117 | id, thresh, | ||
118 | callback, private_data); | ||
119 | } | ||
120 | |||
121 | void nvgpu_nvhost_syncpt_set_min_eq_max_ext( | ||
122 | struct nvgpu_nvhost_dev *nvhost_dev, u32 id) | ||
123 | { | ||
124 | nvhost_syncpt_set_min_eq_max_ext(nvhost_dev->host1x_pdev, id); | ||
125 | } | ||
126 | |||
127 | void nvgpu_nvhost_syncpt_put_ref_ext( | ||
128 | struct nvgpu_nvhost_dev *nvhost_dev, u32 id) | ||
129 | { | ||
130 | nvhost_syncpt_put_ref_ext(nvhost_dev->host1x_pdev, id); | ||
131 | } | ||
132 | |||
133 | u32 nvgpu_nvhost_get_syncpt_host_managed( | ||
134 | struct nvgpu_nvhost_dev *nvhost_dev, | ||
135 | u32 param, const char *syncpt_name) | ||
136 | { | ||
137 | return nvhost_get_syncpt_host_managed(nvhost_dev->host1x_pdev, | ||
138 | param, syncpt_name); | ||
139 | } | ||
140 | |||
141 | u32 nvgpu_nvhost_get_syncpt_client_managed( | ||
142 | struct nvgpu_nvhost_dev *nvhost_dev, | ||
143 | const char *syncpt_name) | ||
144 | { | ||
145 | return nvhost_get_syncpt_client_managed(nvhost_dev->host1x_pdev, | ||
146 | syncpt_name); | ||
147 | } | ||
148 | |||
149 | int nvgpu_nvhost_syncpt_wait_timeout_ext( | ||
150 | struct nvgpu_nvhost_dev *nvhost_dev, u32 id, | ||
151 | u32 thresh, u32 timeout, u32 *value, struct timespec *ts) | ||
152 | { | ||
153 | return nvhost_syncpt_wait_timeout_ext(nvhost_dev->host1x_pdev, | ||
154 | id, thresh, timeout, value, ts); | ||
155 | } | ||
156 | |||
157 | int nvgpu_nvhost_syncpt_read_ext_check( | ||
158 | struct nvgpu_nvhost_dev *nvhost_dev, u32 id, u32 *val) | ||
159 | { | ||
160 | return nvhost_syncpt_read_ext_check(nvhost_dev->host1x_pdev, id, val); | ||
161 | } | ||
162 | |||
163 | u32 nvgpu_nvhost_syncpt_read_maxval( | ||
164 | struct nvgpu_nvhost_dev *nvhost_dev, u32 id) | ||
165 | { | ||
166 | return nvhost_syncpt_read_maxval(nvhost_dev->host1x_pdev, id); | ||
167 | } | ||
168 | |||
169 | void nvgpu_nvhost_syncpt_set_safe_state( | ||
170 | struct nvgpu_nvhost_dev *nvhost_dev, u32 id) | ||
171 | { | ||
172 | u32 val; | ||
173 | |||
174 | /* | ||
175 | * Add large number of increments to current value | ||
176 | * so that all waiters on this syncpoint are released | ||
177 | * | ||
178 | * We don't expect any case where more than 0x10000 increments | ||
179 | * are pending | ||
180 | */ | ||
181 | val = nvhost_syncpt_read_minval(nvhost_dev->host1x_pdev, id); | ||
182 | val += 0x10000; | ||
183 | |||
184 | nvhost_syncpt_set_minval(nvhost_dev->host1x_pdev, id, val); | ||
185 | nvhost_syncpt_set_maxval(nvhost_dev->host1x_pdev, id, val); | ||
186 | } | ||
187 | |||
188 | int nvgpu_nvhost_create_symlink(struct gk20a *g) | ||
189 | { | ||
190 | struct device *dev = dev_from_gk20a(g); | ||
191 | int err = 0; | ||
192 | |||
193 | if (g->nvhost_dev && | ||
194 | (dev->parent != &g->nvhost_dev->host1x_pdev->dev)) { | ||
195 | err = sysfs_create_link(&g->nvhost_dev->host1x_pdev->dev.kobj, | ||
196 | &dev->kobj, | ||
197 | dev_name(dev)); | ||
198 | } | ||
199 | |||
200 | return err; | ||
201 | } | ||
202 | |||
203 | void nvgpu_nvhost_remove_symlink(struct gk20a *g) | ||
204 | { | ||
205 | struct device *dev = dev_from_gk20a(g); | ||
206 | |||
207 | if (g->nvhost_dev && | ||
208 | (dev->parent != &g->nvhost_dev->host1x_pdev->dev)) { | ||
209 | sysfs_remove_link(&g->nvhost_dev->host1x_pdev->dev.kobj, | ||
210 | dev_name(dev)); | ||
211 | } | ||
212 | } | ||
213 | |||
214 | #ifdef CONFIG_SYNC | ||
215 | u32 nvgpu_nvhost_sync_pt_id(struct sync_pt *pt) | ||
216 | { | ||
217 | return nvhost_sync_pt_id(pt); | ||
218 | } | ||
219 | |||
220 | u32 nvgpu_nvhost_sync_pt_thresh(struct sync_pt *pt) | ||
221 | { | ||
222 | return nvhost_sync_pt_thresh(pt); | ||
223 | } | ||
224 | |||
225 | struct sync_fence *nvgpu_nvhost_sync_fdget(int fd) | ||
226 | { | ||
227 | return nvhost_sync_fdget(fd); | ||
228 | } | ||
229 | |||
230 | int nvgpu_nvhost_sync_num_pts(struct sync_fence *fence) | ||
231 | { | ||
232 | return nvhost_sync_num_pts(fence); | ||
233 | } | ||
234 | |||
235 | struct sync_fence *nvgpu_nvhost_sync_create_fence( | ||
236 | struct nvgpu_nvhost_dev *nvhost_dev, | ||
237 | u32 id, u32 thresh, const char *name) | ||
238 | { | ||
239 | struct nvhost_ctrl_sync_fence_info pt = { | ||
240 | .id = id, | ||
241 | .thresh = thresh, | ||
242 | }; | ||
243 | |||
244 | return nvhost_sync_create_fence(nvhost_dev->host1x_pdev, &pt, 1, name); | ||
245 | } | ||
246 | #endif /* CONFIG_SYNC */ | ||
247 | |||
248 | #ifdef CONFIG_TEGRA_T19X_GRHOST | ||
249 | int nvgpu_nvhost_syncpt_unit_interface_get_aperture( | ||
250 | struct nvgpu_nvhost_dev *nvhost_dev, | ||
251 | u64 *base, size_t *size) | ||
252 | { | ||
253 | return nvhost_syncpt_unit_interface_get_aperture( | ||
254 | nvhost_dev->host1x_pdev, (phys_addr_t *)base, size); | ||
255 | } | ||
256 | |||
257 | u32 nvgpu_nvhost_syncpt_unit_interface_get_byte_offset(u32 syncpt_id) | ||
258 | { | ||
259 | return nvhost_syncpt_unit_interface_get_byte_offset(syncpt_id); | ||
260 | } | ||
261 | |||
262 | int nvgpu_nvhost_syncpt_init(struct gk20a *g) | ||
263 | { | ||
264 | int err = 0; | ||
265 | |||
266 | if (!g->has_syncpoints) | ||
267 | return -ENOSYS; | ||
268 | |||
269 | err = nvgpu_get_nvhost_dev(g); | ||
270 | if (err) { | ||
271 | nvgpu_err(g, "host1x device not available"); | ||
272 | g->has_syncpoints = false; | ||
273 | return -ENOSYS; | ||
274 | } | ||
275 | |||
276 | err = nvgpu_nvhost_syncpt_unit_interface_get_aperture( | ||
277 | g->nvhost_dev, | ||
278 | &g->syncpt_unit_base, | ||
279 | &g->syncpt_unit_size); | ||
280 | if (err) { | ||
281 | nvgpu_err(g, "Failed to get syncpt interface"); | ||
282 | g->has_syncpoints = false; | ||
283 | return -ENOSYS; | ||
284 | } | ||
285 | |||
286 | g->syncpt_size = | ||
287 | nvgpu_nvhost_syncpt_unit_interface_get_byte_offset(1); | ||
288 | nvgpu_info(g, "syncpt_unit_base %llx syncpt_unit_size %zx size %x\n", | ||
289 | g->syncpt_unit_base, g->syncpt_unit_size, | ||
290 | g->syncpt_size); | ||
291 | |||
292 | return 0; | ||
293 | } | ||
294 | #endif | ||