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/common/linux/vgpu/gv11b/vgpu_fifo_gv11b.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/common/linux/vgpu/gv11b/vgpu_fifo_gv11b.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/vgpu/gv11b/vgpu_fifo_gv11b.c | 139 |
1 files changed, 0 insertions, 139 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/vgpu/gv11b/vgpu_fifo_gv11b.c b/drivers/gpu/nvgpu/common/linux/vgpu/gv11b/vgpu_fifo_gv11b.c deleted file mode 100644 index c2129e4b..00000000 --- a/drivers/gpu/nvgpu/common/linux/vgpu/gv11b/vgpu_fifo_gv11b.c +++ /dev/null | |||
@@ -1,139 +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 <gk20a/gk20a.h> | ||
18 | |||
19 | #include "common/linux/vgpu/vgpu.h" | ||
20 | #include "gv11b/fifo_gv11b.h" | ||
21 | #include <nvgpu/nvhost.h> | ||
22 | #include <nvgpu/vgpu/tegra_vgpu.h> | ||
23 | |||
24 | #ifdef CONFIG_TEGRA_GK20A_NVHOST | ||
25 | |||
26 | static int set_syncpt_ro_map_gpu_va_locked(struct vm_gk20a *vm) | ||
27 | { | ||
28 | int err; | ||
29 | struct gk20a *g = gk20a_from_vm(vm); | ||
30 | struct tegra_vgpu_cmd_msg msg = {}; | ||
31 | struct tegra_vgpu_map_syncpt_params *p = &msg.params.map_syncpt; | ||
32 | |||
33 | if (vm->syncpt_ro_map_gpu_va) | ||
34 | return 0; | ||
35 | |||
36 | vm->syncpt_ro_map_gpu_va = __nvgpu_vm_alloc_va(vm, | ||
37 | g->syncpt_unit_size, | ||
38 | gmmu_page_size_kernel); | ||
39 | if (!vm->syncpt_ro_map_gpu_va) { | ||
40 | nvgpu_err(g, "allocating read-only va space failed"); | ||
41 | return -ENOMEM; | ||
42 | } | ||
43 | |||
44 | msg.cmd = TEGRA_VGPU_CMD_MAP_SYNCPT; | ||
45 | msg.handle = vgpu_get_handle(g); | ||
46 | p->as_handle = vm->handle; | ||
47 | p->gpu_va = vm->syncpt_ro_map_gpu_va; | ||
48 | p->len = g->syncpt_unit_size; | ||
49 | p->offset = 0; | ||
50 | p->prot = TEGRA_VGPU_MAP_PROT_READ_ONLY; | ||
51 | err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); | ||
52 | err = err ? err : msg.ret; | ||
53 | if (err) { | ||
54 | nvgpu_err(g, | ||
55 | "mapping read-only va space failed err %d", | ||
56 | err); | ||
57 | __nvgpu_vm_free_va(vm, vm->syncpt_ro_map_gpu_va, | ||
58 | gmmu_page_size_kernel); | ||
59 | vm->syncpt_ro_map_gpu_va = 0; | ||
60 | return err; | ||
61 | } | ||
62 | |||
63 | return 0; | ||
64 | } | ||
65 | |||
66 | int vgpu_gv11b_fifo_alloc_syncpt_buf(struct channel_gk20a *c, | ||
67 | u32 syncpt_id, struct nvgpu_mem *syncpt_buf) | ||
68 | { | ||
69 | int err; | ||
70 | struct gk20a *g = c->g; | ||
71 | struct tegra_vgpu_cmd_msg msg = {}; | ||
72 | struct tegra_vgpu_map_syncpt_params *p = &msg.params.map_syncpt; | ||
73 | |||
74 | /* | ||
75 | * Add ro map for complete sync point shim range in vm. | ||
76 | * All channels sharing same vm will share same ro mapping. | ||
77 | * Create rw map for current channel sync point. | ||
78 | */ | ||
79 | nvgpu_mutex_acquire(&c->vm->syncpt_ro_map_lock); | ||
80 | err = set_syncpt_ro_map_gpu_va_locked(c->vm); | ||
81 | nvgpu_mutex_release(&c->vm->syncpt_ro_map_lock); | ||
82 | if (err) | ||
83 | return err; | ||
84 | |||
85 | syncpt_buf->gpu_va = __nvgpu_vm_alloc_va(c->vm, g->syncpt_size, | ||
86 | gmmu_page_size_kernel); | ||
87 | if (!syncpt_buf->gpu_va) { | ||
88 | nvgpu_err(g, "allocating syncpt va space failed"); | ||
89 | return -ENOMEM; | ||
90 | } | ||
91 | |||
92 | msg.cmd = TEGRA_VGPU_CMD_MAP_SYNCPT; | ||
93 | msg.handle = vgpu_get_handle(g); | ||
94 | p->as_handle = c->vm->handle; | ||
95 | p->gpu_va = syncpt_buf->gpu_va; | ||
96 | p->len = g->syncpt_size; | ||
97 | p->offset = | ||
98 | nvgpu_nvhost_syncpt_unit_interface_get_byte_offset(syncpt_id); | ||
99 | p->prot = TEGRA_VGPU_MAP_PROT_NONE; | ||
100 | err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); | ||
101 | err = err ? err : msg.ret; | ||
102 | if (err) { | ||
103 | nvgpu_err(g, "mapping syncpt va space failed err %d", err); | ||
104 | __nvgpu_vm_free_va(c->vm, syncpt_buf->gpu_va, | ||
105 | gmmu_page_size_kernel); | ||
106 | return err; | ||
107 | } | ||
108 | |||
109 | return 0; | ||
110 | } | ||
111 | |||
112 | int vgpu_gv11b_fifo_get_sync_ro_map(struct vm_gk20a *vm, | ||
113 | u64 *base_gpuva, u32 *sync_size) | ||
114 | { | ||
115 | struct gk20a *g = gk20a_from_vm(vm); | ||
116 | int err; | ||
117 | |||
118 | nvgpu_mutex_acquire(&vm->syncpt_ro_map_lock); | ||
119 | err = set_syncpt_ro_map_gpu_va_locked(vm); | ||
120 | nvgpu_mutex_release(&vm->syncpt_ro_map_lock); | ||
121 | if (err) | ||
122 | return err; | ||
123 | |||
124 | *base_gpuva = vm->syncpt_ro_map_gpu_va; | ||
125 | *sync_size = g->syncpt_size; | ||
126 | |||
127 | return 0; | ||
128 | } | ||
129 | #endif /* CONFIG_TEGRA_GK20A_NVHOST */ | ||
130 | |||
131 | int vgpu_gv11b_init_fifo_setup_hw(struct gk20a *g) | ||
132 | { | ||
133 | struct fifo_gk20a *f = &g->fifo; | ||
134 | struct vgpu_priv_data *priv = vgpu_get_priv_data(g); | ||
135 | |||
136 | f->max_subctx_count = priv->constants.max_subctx_count; | ||
137 | |||
138 | return 0; | ||
139 | } | ||