diff options
author | Alex Waterman <alexw@nvidia.com> | 2017-03-21 17:32:13 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-04-06 21:14:58 -0400 |
commit | 8f2d4a3f4a0acc81bae6725d30506e92651a42b5 (patch) | |
tree | 5cfe8a72fc824d167d3ce0f207621e1e4eb88391 /drivers/gpu/nvgpu/include | |
parent | c9665079d7b12f22a847c62587724b4ee120ca6e (diff) |
gpu: nvgpu: Move DMA API to dma.h
Make an nvgpu DMA API include file so that the intricacies of the
Linux DMA API can be hidden from the calling code.
Also document the nvgpu DMA API.
JIRA NVGPU-12
Change-Id: I7578e4c726ad46344b7921179d95861858e9a27e
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1323326
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/include')
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/dma.h | 312 |
1 files changed, 312 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/dma.h b/drivers/gpu/nvgpu/include/nvgpu/dma.h new file mode 100644 index 00000000..d4fad584 --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/dma.h | |||
@@ -0,0 +1,312 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, 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 | #ifndef __NVGPU_DMA_H__ | ||
18 | #define __NVGPU_DMA_H__ | ||
19 | |||
20 | #include <nvgpu/types.h> | ||
21 | |||
22 | struct gk20a; | ||
23 | struct vm_gk20a; | ||
24 | struct nvgpu_mem; | ||
25 | |||
26 | /* | ||
27 | * Flags for the below gk20a_gmmu_{alloc,alloc_map}_flags* | ||
28 | */ | ||
29 | |||
30 | /* | ||
31 | * Don't create a virtual kernel mapping for the buffer but only allocate it; | ||
32 | * this may save some resources. The buffer can be mapped later explicitly. | ||
33 | */ | ||
34 | #define NVGPU_DMA_NO_KERNEL_MAPPING (1 << 0) | ||
35 | |||
36 | /* | ||
37 | * Don't allow building the buffer from individual pages but require a | ||
38 | * physically contiguous block. | ||
39 | */ | ||
40 | #define NVGPU_DMA_FORCE_CONTIGUOUS (1 << 1) | ||
41 | |||
42 | /* | ||
43 | * Make the mapping read-only. | ||
44 | */ | ||
45 | #define NVGPU_DMA_READ_ONLY (1 << 2) | ||
46 | |||
47 | /** | ||
48 | * gk20a_gmmu_alloc - Allocate DMA memory | ||
49 | * | ||
50 | * @g - The GPU. | ||
51 | * @size - Size of the allocation in bytes. | ||
52 | * @mem - Struct for storing the allocation information. | ||
53 | * | ||
54 | * Allocate memory suitable for doing DMA. Store the allocation info in @mem. | ||
55 | * Returns 0 on success and a suitable error code when there's an error. This | ||
56 | * memory can be either placed in VIDMEM or SYSMEM, which ever is more | ||
57 | * convenient for the driver. | ||
58 | */ | ||
59 | int gk20a_gmmu_alloc(struct gk20a *g, size_t size, struct nvgpu_mem *mem); | ||
60 | |||
61 | /** | ||
62 | * gk20a_gmmu_alloc_flags - Allocate DMA memory | ||
63 | * | ||
64 | * @g - The GPU. | ||
65 | * @flags - Flags modifying the operation of the DMA allocation. | ||
66 | * @size - Size of the allocation in bytes. | ||
67 | * @mem - Struct for storing the allocation information. | ||
68 | * | ||
69 | * Allocate memory suitable for doing DMA. Store the allocation info in @mem. | ||
70 | * Returns 0 on success and a suitable error code when there's an error. This | ||
71 | * memory can be either placed in VIDMEM or SYSMEM, which ever is more | ||
72 | * convenient for the driver. | ||
73 | * | ||
74 | * The following flags are accepted: | ||
75 | * | ||
76 | * %NVGPU_DMA_NO_KERNEL_MAPPING | ||
77 | * %NVGPU_DMA_FORCE_CONTIGUOUS | ||
78 | * %NVGPU_DMA_READ_ONLY | ||
79 | */ | ||
80 | int gk20a_gmmu_alloc_flags(struct gk20a *g, unsigned long flags, size_t size, | ||
81 | struct nvgpu_mem *mem); | ||
82 | |||
83 | /** | ||
84 | * gk20a_gmmu_alloc_sys - Allocate DMA memory | ||
85 | * | ||
86 | * @g - The GPU. | ||
87 | * @size - Size of the allocation in bytes. | ||
88 | * @mem - Struct for storing the allocation information. | ||
89 | * | ||
90 | * Allocate memory suitable for doing DMA. Store the allocation info in @mem. | ||
91 | * Returns 0 on success and a suitable error code when there's an error. This | ||
92 | * allocates memory specifically in SYSMEM. | ||
93 | */ | ||
94 | int gk20a_gmmu_alloc_sys(struct gk20a *g, size_t size, struct nvgpu_mem *mem); | ||
95 | |||
96 | /** | ||
97 | * gk20a_gmmu_alloc_flags_sys - Allocate DMA memory | ||
98 | * | ||
99 | * @g - The GPU. | ||
100 | * @flags - Flags modifying the operation of the DMA allocation. | ||
101 | * @size - Size of the allocation in bytes. | ||
102 | * @mem - Struct for storing the allocation information. | ||
103 | * | ||
104 | * Allocate memory suitable for doing DMA. Store the allocation info in @mem. | ||
105 | * Returns 0 on success and a suitable error code when there's an error. This | ||
106 | * allocates memory specifically in SYSMEM. | ||
107 | * | ||
108 | * The following flags are accepted: | ||
109 | * | ||
110 | * %NVGPU_DMA_NO_KERNEL_MAPPING | ||
111 | * %NVGPU_DMA_FORCE_CONTIGUOUS | ||
112 | * %NVGPU_DMA_READ_ONLY | ||
113 | */ | ||
114 | int gk20a_gmmu_alloc_flags_sys(struct gk20a *g, unsigned long flags, | ||
115 | size_t size, struct nvgpu_mem *mem); | ||
116 | |||
117 | /** | ||
118 | * gk20a_gmmu_alloc_vid - Allocate DMA memory | ||
119 | * | ||
120 | * @g - The GPU. | ||
121 | * @size - Size of the allocation in bytes. | ||
122 | * @mem - Struct for storing the allocation information. | ||
123 | * | ||
124 | * Allocate memory suitable for doing DMA. Store the allocation info in @mem. | ||
125 | * Returns 0 on success and a suitable error code when there's an error. This | ||
126 | * allocates memory specifically in VIDMEM. | ||
127 | */ | ||
128 | int gk20a_gmmu_alloc_vid(struct gk20a *g, size_t size, struct nvgpu_mem *mem); | ||
129 | |||
130 | /** | ||
131 | * gk20a_gmmu_alloc_flags_vid - Allocate DMA memory | ||
132 | * | ||
133 | * @g - The GPU. | ||
134 | * @flags - Flags modifying the operation of the DMA allocation. | ||
135 | * @size - Size of the allocation in bytes. | ||
136 | * @mem - Struct for storing the allocation information. | ||
137 | * | ||
138 | * Allocate memory suitable for doing DMA. Store the allocation info in @mem. | ||
139 | * Returns 0 on success and a suitable error code when there's an error. This | ||
140 | * allocates memory specifically in VIDMEM. | ||
141 | * | ||
142 | * Only the following flags are accepted: | ||
143 | * | ||
144 | * %NVGPU_DMA_NO_KERNEL_MAPPING | ||
145 | * | ||
146 | */ | ||
147 | int gk20a_gmmu_alloc_flags_vid(struct gk20a *g, unsigned long flags, | ||
148 | size_t size, struct nvgpu_mem *mem); | ||
149 | |||
150 | /** | ||
151 | * gk20a_gmmu_alloc_flags_vid_at - Allocate DMA memory | ||
152 | * | ||
153 | * @g - The GPU. | ||
154 | * @flags - Flags modifying the operation of the DMA allocation. | ||
155 | * @size - Size of the allocation in bytes. | ||
156 | * @mem - Struct for storing the allocation information. | ||
157 | * @at - A specific location to attempt to allocate memory from or 0 if the | ||
158 | * caller does not care what the address is. | ||
159 | * | ||
160 | * Allocate memory suitable for doing DMA. Store the allocation info in @mem. | ||
161 | * Returns 0 on success and a suitable error code when there's an error. This | ||
162 | * allocates memory specifically in VIDMEM. | ||
163 | * | ||
164 | * Only the following flags are accepted: | ||
165 | * | ||
166 | * %NVGPU_DMA_NO_KERNEL_MAPPING | ||
167 | */ | ||
168 | int gk20a_gmmu_alloc_flags_vid_at(struct gk20a *g, unsigned long flags, | ||
169 | size_t size, struct nvgpu_mem *mem, dma_addr_t at); | ||
170 | |||
171 | /** | ||
172 | * gk20a_gmmu_free - Free a DMA allocation | ||
173 | * | ||
174 | * @g - The GPU. | ||
175 | * @mem - An allocation to free. | ||
176 | * | ||
177 | * Free memory created with any of: | ||
178 | * | ||
179 | * gk20a_gmmu_alloc() | ||
180 | * gk20a_gmmu_alloc_flags() | ||
181 | * gk20a_gmmu_alloc_sys() | ||
182 | * gk20a_gmmu_alloc_flags_sys() | ||
183 | * gk20a_gmmu_alloc_vid() | ||
184 | * gk20a_gmmu_alloc_flags_vid() | ||
185 | * gk20a_gmmu_alloc_flags_vid_at() | ||
186 | */ | ||
187 | void gk20a_gmmu_free(struct gk20a *g, struct nvgpu_mem *mem); | ||
188 | |||
189 | /** | ||
190 | * gk20a_gmmu_alloc_map - Allocate DMA memory and map into GMMU. | ||
191 | * | ||
192 | * @vm - VM context for GMMU mapping. | ||
193 | * @size - Size of the allocation in bytes. | ||
194 | * @mem - Struct for storing the allocation information. | ||
195 | * | ||
196 | * Allocate memory suitable for doing DMA and map that memory into the GMMU. | ||
197 | * Note this is different than mapping it into the CPU. This memory can be | ||
198 | * either placed in VIDMEM or SYSMEM, which ever is more convenient for the | ||
199 | * driver. | ||
200 | */ | ||
201 | int gk20a_gmmu_alloc_map(struct vm_gk20a *vm, size_t size, | ||
202 | struct nvgpu_mem *mem); | ||
203 | |||
204 | /** | ||
205 | * gk20a_gmmu_alloc_map_flags - Allocate DMA memory and map into GMMU. | ||
206 | * | ||
207 | * @vm - VM context for GMMU mapping. | ||
208 | * @flags - Flags modifying the operation of the DMA allocation. | ||
209 | * @size - Size of the allocation in bytes. | ||
210 | * @mem - Struct for storing the allocation information. | ||
211 | * | ||
212 | * Allocate memory suitable for doing DMA and map that memory into the GMMU. | ||
213 | * Note this is different than mapping it into the CPU. This memory can be | ||
214 | * either placed in VIDMEM or SYSMEM, which ever is more convenient for the | ||
215 | * driver. | ||
216 | * | ||
217 | * This version passes @flags on to the underlying DMA allocation. The accepted | ||
218 | * flags are: | ||
219 | * | ||
220 | * %NVGPU_DMA_NO_KERNEL_MAPPING | ||
221 | * %NVGPU_DMA_FORCE_CONTIGUOUS | ||
222 | * %NVGPU_DMA_READ_ONLY | ||
223 | */ | ||
224 | int gk20a_gmmu_alloc_map_flags(struct vm_gk20a *vm, unsigned long flags, | ||
225 | size_t size, struct nvgpu_mem *mem); | ||
226 | |||
227 | /** | ||
228 | * gk20a_gmmu_alloc_map_sys - Allocate DMA memory and map into GMMU. | ||
229 | * | ||
230 | * @vm - VM context for GMMU mapping. | ||
231 | * @size - Size of the allocation in bytes. | ||
232 | * @mem - Struct for storing the allocation information. | ||
233 | * | ||
234 | * Allocate memory suitable for doing DMA and map that memory into the GMMU. | ||
235 | * This memory will be placed in SYSMEM. | ||
236 | */ | ||
237 | int gk20a_gmmu_alloc_map_sys(struct vm_gk20a *vm, size_t size, | ||
238 | struct nvgpu_mem *mem); | ||
239 | |||
240 | /** | ||
241 | * gk20a_gmmu_alloc_map_flags_sys - Allocate DMA memory and map into GMMU. | ||
242 | * | ||
243 | * @vm - VM context for GMMU mapping. | ||
244 | * @flags - Flags modifying the operation of the DMA allocation. | ||
245 | * @size - Size of the allocation in bytes. | ||
246 | * @mem - Struct for storing the allocation information. | ||
247 | * | ||
248 | * Allocate memory suitable for doing DMA and map that memory into the GMMU. | ||
249 | * This memory will be placed in SYSMEM. | ||
250 | * | ||
251 | * This version passes @flags on to the underlying DMA allocation. The accepted | ||
252 | * flags are: | ||
253 | * | ||
254 | * %NVGPU_DMA_NO_KERNEL_MAPPING | ||
255 | * %NVGPU_DMA_FORCE_CONTIGUOUS | ||
256 | * %NVGPU_DMA_READ_ONLY | ||
257 | */ | ||
258 | int gk20a_gmmu_alloc_map_flags_sys(struct vm_gk20a *vm, unsigned long flags, | ||
259 | size_t size, struct nvgpu_mem *mem); | ||
260 | |||
261 | /** | ||
262 | * gk20a_gmmu_alloc_map_vid - Allocate DMA memory and map into GMMU. | ||
263 | * | ||
264 | * @vm - VM context for GMMU mapping. | ||
265 | * @size - Size of the allocation in bytes. | ||
266 | * @mem - Struct for storing the allocation information. | ||
267 | * | ||
268 | * Allocate memory suitable for doing DMA and map that memory into the GMMU. | ||
269 | * This memory will be placed in VIDMEM. | ||
270 | */ | ||
271 | int gk20a_gmmu_alloc_map_vid(struct vm_gk20a *vm, size_t size, | ||
272 | struct nvgpu_mem *mem); | ||
273 | |||
274 | /** | ||
275 | * gk20a_gmmu_alloc_map_flags_vid - Allocate DMA memory and map into GMMU. | ||
276 | * | ||
277 | * @vm - VM context for GMMU mapping. | ||
278 | * @flags - Flags modifying the operation of the DMA allocation. | ||
279 | * @size - Size of the allocation in bytes. | ||
280 | * @mem - Struct for storing the allocation information. | ||
281 | * | ||
282 | * Allocate memory suitable for doing DMA and map that memory into the GMMU. | ||
283 | * This memory will be placed in VIDMEM. | ||
284 | * | ||
285 | * This version passes @flags on to the underlying DMA allocation. The accepted | ||
286 | * flags are: | ||
287 | * | ||
288 | * %NVGPU_DMA_NO_KERNEL_MAPPING | ||
289 | * %NVGPU_DMA_FORCE_CONTIGUOUS | ||
290 | * %NVGPU_DMA_READ_ONLY | ||
291 | */ | ||
292 | int gk20a_gmmu_alloc_map_flags_vid(struct vm_gk20a *vm, unsigned long flags, | ||
293 | size_t size, struct nvgpu_mem *mem); | ||
294 | |||
295 | /** | ||
296 | * gk20a_gmmu_unmap_free - Free a DMA allocation | ||
297 | * | ||
298 | * @g - The GPU. | ||
299 | * @mem - An allocation to free. | ||
300 | * | ||
301 | * Free memory created with any of: | ||
302 | * | ||
303 | * gk20a_gmmu_alloc_map() | ||
304 | * gk20a_gmmu_alloc_map_flags() | ||
305 | * gk20a_gmmu_alloc_map_sys() | ||
306 | * gk20a_gmmu_alloc_map_flags_sys() | ||
307 | * gk20a_gmmu_alloc_map_vid() | ||
308 | * gk20a_gmmu_alloc_map_flags_vid() | ||
309 | */ | ||
310 | void gk20a_gmmu_unmap_free(struct vm_gk20a *vm, struct nvgpu_mem *mem); | ||
311 | |||
312 | #endif | ||