summaryrefslogtreecommitdiffstats
path: root/include/uapi/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/uapi/linux')
-rw-r--r--include/uapi/linux/nvmap.h376
1 files changed, 376 insertions, 0 deletions
diff --git a/include/uapi/linux/nvmap.h b/include/uapi/linux/nvmap.h
new file mode 100644
index 000000000..2b2d12a60
--- /dev/null
+++ b/include/uapi/linux/nvmap.h
@@ -0,0 +1,376 @@
1/*
2 * include/uapi/linux/nvmap.h
3 *
4 * structure declarations for nvmem and nvmap user-space ioctls
5 *
6 * Copyright (c) 2009-2019, NVIDIA CORPORATION. All rights reserved.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 */
17
18#include <linux/ioctl.h>
19#include <linux/types.h>
20
21#ifndef __UAPI_LINUX_NVMAP_H
22#define __UAPI_LINUX_NVMAP_H
23
24/*
25 * DOC: NvMap Userspace API
26 *
27 * create a client by opening /dev/nvmap
28 * most operations handled via following ioctls
29 *
30 */
31enum {
32 NVMAP_HANDLE_PARAM_SIZE = 1,
33 NVMAP_HANDLE_PARAM_ALIGNMENT,
34 NVMAP_HANDLE_PARAM_BASE,
35 NVMAP_HANDLE_PARAM_HEAP,
36 NVMAP_HANDLE_PARAM_KIND,
37 NVMAP_HANDLE_PARAM_COMPR, /* ignored, to be removed */
38};
39
40enum {
41 NVMAP_CACHE_OP_WB = 0,
42 NVMAP_CACHE_OP_INV,
43 NVMAP_CACHE_OP_WB_INV,
44};
45
46enum {
47 NVMAP_PAGES_UNRESERVE = 0,
48 NVMAP_PAGES_RESERVE,
49 NVMAP_INSERT_PAGES_ON_UNRESERVE,
50 NVMAP_PAGES_PROT_AND_CLEAN,
51};
52
53#define NVMAP_ELEM_SIZE_U64 (1 << 31)
54
55struct nvmap_create_handle {
56 union {
57 struct {
58 union {
59 /* size will be overwritten */
60 __u32 size; /* CreateHandle */
61 __s32 fd; /* DmaBufFd or FromFd */
62 };
63 __u32 handle; /* returns nvmap handle */
64 };
65 struct {
66 /* one is input parameter, and other is output parameter
67 * since its a union please note that input parameter
68 * will be overwritten once ioctl returns
69 */
70 union {
71 __u64 ivm_id; /* CreateHandle from ivm*/
72 __s32 ivm_handle;/* Get ivm_id from handle */
73 };
74 };
75 struct {
76 union {
77 /* size64 will be overwritten */
78 __u64 size64; /* CreateHandle */
79 __u32 handle64; /* returns nvmap handle */
80 };
81 };
82 };
83};
84
85struct nvmap_create_handle_from_va {
86 __u64 va; /* FromVA*/
87 __u32 size; /* non-zero for partial memory VMA. zero for end of VMA */
88 __u32 flags; /* wb/wc/uc/iwb, tag etc. */
89 union {
90 __u32 handle; /* returns nvmap handle */
91 __u64 size64; /* used when size is 0 */
92 };
93};
94
95struct nvmap_gup_test {
96 __u64 va; /* FromVA*/
97 __u32 handle; /* returns nvmap handle */
98 __u32 result; /* result=1 for pass, result=-err for failure */
99};
100
101struct nvmap_alloc_handle {
102 __u32 handle; /* nvmap handle */
103 __u32 heap_mask; /* heaps to allocate from */
104 __u32 flags; /* wb/wc/uc/iwb etc. */
105 __u32 align; /* min alignment necessary */
106};
107
108struct nvmap_alloc_ivm_handle {
109 __u32 handle; /* nvmap handle */
110 __u32 heap_mask; /* heaps to allocate from */
111 __u32 flags; /* wb/wc/uc/iwb etc. */
112 __u32 align; /* min alignment necessary */
113 __u32 peer; /* peer with whom handle must be shared. Used
114 * only for NVMAP_HEAP_CARVEOUT_IVM
115 */
116};
117
118struct nvmap_alloc_kind_handle {
119 __u32 handle; /* nvmap handle */
120 __u32 heap_mask;
121 __u32 flags;
122 __u32 align;
123 __u8 kind;
124 __u8 comp_tags;
125};
126
127struct nvmap_map_caller {
128 __u32 handle; /* nvmap handle */
129 __u32 offset; /* offset into hmem; should be page-aligned */
130 __u32 length; /* number of bytes to map */
131 __u32 flags; /* maps as wb/iwb etc. */
132 unsigned long addr; /* user pointer */
133};
134
135#ifdef CONFIG_COMPAT
136struct nvmap_map_caller_32 {
137 __u32 handle; /* nvmap handle */
138 __u32 offset; /* offset into hmem; should be page-aligned */
139 __u32 length; /* number of bytes to map */
140 __u32 flags; /* maps as wb/iwb etc. */
141 __u32 addr; /* user pointer*/
142};
143#endif
144
145struct nvmap_rw_handle {
146 unsigned long addr; /* user pointer*/
147 __u32 handle; /* nvmap handle */
148 __u32 offset; /* offset into hmem */
149 __u32 elem_size; /* individual atom size */
150 __u32 hmem_stride; /* delta in bytes between atoms in hmem */
151 __u32 user_stride; /* delta in bytes between atoms in user */
152 __u32 count; /* number of atoms to copy */
153};
154
155struct nvmap_rw_handle_64 {
156 unsigned long addr; /* user pointer*/
157 __u32 handle; /* nvmap handle */
158 __u64 offset; /* offset into hmem */
159 __u64 elem_size; /* individual atom size */
160 __u64 hmem_stride; /* delta in bytes between atoms in hmem */
161 __u64 user_stride; /* delta in bytes between atoms in user */
162 __u64 count; /* number of atoms to copy */
163};
164
165#ifdef CONFIG_COMPAT
166struct nvmap_rw_handle_32 {
167 __u32 addr; /* user pointer */
168 __u32 handle; /* nvmap handle */
169 __u32 offset; /* offset into hmem */
170 __u32 elem_size; /* individual atom size */
171 __u32 hmem_stride; /* delta in bytes between atoms in hmem */
172 __u32 user_stride; /* delta in bytes between atoms in user */
173 __u32 count; /* number of atoms to copy */
174};
175#endif
176
177struct nvmap_pin_handle {
178 __u32 *handles; /* array of handles to pin/unpin */
179 unsigned long *addr; /* array of addresses to return */
180 __u32 count; /* number of entries in handles */
181};
182
183#ifdef CONFIG_COMPAT
184struct nvmap_pin_handle_32 {
185 __u32 handles; /* array of handles to pin/unpin */
186 __u32 addr; /* array of addresses to return */
187 __u32 count; /* number of entries in handles */
188};
189#endif
190
191struct nvmap_handle_param {
192 __u32 handle; /* nvmap handle */
193 __u32 param; /* size/align/base/heap etc. */
194 unsigned long result; /* returns requested info*/
195};
196
197#ifdef CONFIG_COMPAT
198struct nvmap_handle_param_32 {
199 __u32 handle; /* nvmap handle */
200 __u32 param; /* size/align/base/heap etc. */
201 __u32 result; /* returns requested info*/
202};
203#endif
204
205struct nvmap_cache_op {
206 unsigned long addr; /* user pointer*/
207 __u32 handle; /* nvmap handle */
208 __u32 len; /* bytes to flush */
209 __s32 op; /* wb/wb_inv/inv */
210};
211
212struct nvmap_cache_op_64 {
213 unsigned long addr; /* user pointer*/
214 __u32 handle; /* nvmap handle */
215 __u64 len; /* bytes to flush */
216 __s32 op; /* wb/wb_inv/inv */
217};
218
219#ifdef CONFIG_COMPAT
220struct nvmap_cache_op_32 {
221 __u32 addr; /* user pointer*/
222 __u32 handle; /* nvmap handle */
223 __u32 len; /* bytes to flush */
224 __s32 op; /* wb/wb_inv/inv */
225};
226#endif
227
228struct nvmap_cache_op_list {
229 __u64 handles; /* Ptr to u32 type array, holding handles */
230 __u64 offsets; /* Ptr to u32 type array, holding offsets
231 * into handle mem */
232 __u64 sizes; /* Ptr to u32 type array, holindg sizes of memory
233 * regions within each handle */
234 __u32 nr; /* Number of handles */
235 __s32 op; /* wb/wb_inv/inv */
236};
237
238struct nvmap_debugfs_handles_header {
239 __u8 version;
240};
241
242struct nvmap_debugfs_handles_entry {
243 __u64 base;
244 __u64 size;
245 __u32 flags;
246 __u32 share_count;
247 __u64 mapped_size;
248};
249
250struct nvmap_set_tag_label {
251 __u32 tag;
252 __u32 len; /* in: label length
253 out: number of characters copied */
254 __u64 addr; /* in: pointer to label or NULL to remove */
255};
256
257struct nvmap_available_heaps {
258 __u64 heaps; /* heaps bitmask */
259};
260
261struct nvmap_heap_size {
262 __u32 heap;
263 __u64 size;
264};
265
266#define NVMAP_IOC_MAGIC 'N'
267
268/* Creates a new memory handle. On input, the argument is the size of the new
269 * handle; on return, the argument is the name of the new handle
270 */
271#define NVMAP_IOC_CREATE _IOWR(NVMAP_IOC_MAGIC, 0, struct nvmap_create_handle)
272#define NVMAP_IOC_CREATE_64 \
273 _IOWR(NVMAP_IOC_MAGIC, 1, struct nvmap_create_handle)
274#define NVMAP_IOC_FROM_ID _IOWR(NVMAP_IOC_MAGIC, 2, struct nvmap_create_handle)
275
276/* Actually allocates memory for the specified handle */
277#define NVMAP_IOC_ALLOC _IOW(NVMAP_IOC_MAGIC, 3, struct nvmap_alloc_handle)
278
279/* Frees a memory handle, unpinning any pinned pages and unmapping any mappings
280 */
281#define NVMAP_IOC_FREE _IO(NVMAP_IOC_MAGIC, 4)
282
283/* Maps the region of the specified handle into a user-provided virtual address
284 * that was previously created via an mmap syscall on this fd */
285#define NVMAP_IOC_MMAP _IOWR(NVMAP_IOC_MAGIC, 5, struct nvmap_map_caller)
286#ifdef CONFIG_COMPAT
287#define NVMAP_IOC_MMAP_32 _IOWR(NVMAP_IOC_MAGIC, 5, struct nvmap_map_caller_32)
288#endif
289
290/* Reads/writes data (possibly strided) from a user-provided buffer into the
291 * hmem at the specified offset */
292#define NVMAP_IOC_WRITE _IOW(NVMAP_IOC_MAGIC, 6, struct nvmap_rw_handle)
293#define NVMAP_IOC_READ _IOW(NVMAP_IOC_MAGIC, 7, struct nvmap_rw_handle)
294#ifdef CONFIG_COMPAT
295#define NVMAP_IOC_WRITE_32 _IOW(NVMAP_IOC_MAGIC, 6, struct nvmap_rw_handle_32)
296#define NVMAP_IOC_READ_32 _IOW(NVMAP_IOC_MAGIC, 7, struct nvmap_rw_handle_32)
297#endif
298#define NVMAP_IOC_WRITE_64 \
299 _IOW(NVMAP_IOC_MAGIC, 6, struct nvmap_rw_handle_64)
300#define NVMAP_IOC_READ_64 \
301 _IOW(NVMAP_IOC_MAGIC, 7, struct nvmap_rw_handle_64)
302
303#define NVMAP_IOC_PARAM _IOWR(NVMAP_IOC_MAGIC, 8, struct nvmap_handle_param)
304#ifdef CONFIG_COMPAT
305#define NVMAP_IOC_PARAM_32 _IOWR(NVMAP_IOC_MAGIC, 8, struct nvmap_handle_param_32)
306#endif
307
308/* Pins a list of memory handles into IO-addressable memory (either IOVMM
309 * space or physical memory, depending on the allocation), and returns the
310 * address. Handles may be pinned recursively. */
311#define NVMAP_IOC_PIN_MULT _IOWR(NVMAP_IOC_MAGIC, 10, struct nvmap_pin_handle)
312#define NVMAP_IOC_UNPIN_MULT _IOW(NVMAP_IOC_MAGIC, 11, struct nvmap_pin_handle)
313#ifdef CONFIG_COMPAT
314#define NVMAP_IOC_PIN_MULT_32 _IOWR(NVMAP_IOC_MAGIC, 10, struct nvmap_pin_handle_32)
315#define NVMAP_IOC_UNPIN_MULT_32 _IOW(NVMAP_IOC_MAGIC, 11, struct nvmap_pin_handle_32)
316#endif
317
318#define NVMAP_IOC_CACHE _IOW(NVMAP_IOC_MAGIC, 12, struct nvmap_cache_op)
319#define NVMAP_IOC_CACHE_64 _IOW(NVMAP_IOC_MAGIC, 12, struct nvmap_cache_op_64)
320#ifdef CONFIG_COMPAT
321#define NVMAP_IOC_CACHE_32 _IOW(NVMAP_IOC_MAGIC, 12, struct nvmap_cache_op_32)
322#endif
323
324/* Returns a global ID usable to allow a remote process to create a handle
325 * reference to the same handle */
326#define NVMAP_IOC_GET_ID _IOWR(NVMAP_IOC_MAGIC, 13, struct nvmap_create_handle)
327
328/* Returns a dma-buf fd usable to allow a remote process to create a handle
329 * reference to the same handle */
330#define NVMAP_IOC_SHARE _IOWR(NVMAP_IOC_MAGIC, 14, struct nvmap_create_handle)
331
332/* Returns a file id that allows a remote process to create a handle
333 * reference to the same handle */
334#define NVMAP_IOC_GET_FD _IOWR(NVMAP_IOC_MAGIC, 15, struct nvmap_create_handle)
335
336/* Create a new memory handle from file id passed */
337#define NVMAP_IOC_FROM_FD _IOWR(NVMAP_IOC_MAGIC, 16, struct nvmap_create_handle)
338
339/* Perform cache maintenance on a list of handles. */
340#define NVMAP_IOC_CACHE_LIST _IOW(NVMAP_IOC_MAGIC, 17, \
341 struct nvmap_cache_op_list)
342/* Perform reserve operation on a list of handles. */
343#define NVMAP_IOC_RESERVE _IOW(NVMAP_IOC_MAGIC, 18, \
344 struct nvmap_cache_op_list)
345
346#define NVMAP_IOC_FROM_IVC_ID _IOWR(NVMAP_IOC_MAGIC, 19, struct nvmap_create_handle)
347#define NVMAP_IOC_GET_IVC_ID _IOWR(NVMAP_IOC_MAGIC, 20, struct nvmap_create_handle)
348#define NVMAP_IOC_GET_IVM_HEAPS _IOR(NVMAP_IOC_MAGIC, 21, unsigned int)
349
350/* Create a new memory handle from VA passed */
351#define NVMAP_IOC_FROM_VA _IOWR(NVMAP_IOC_MAGIC, 22, struct nvmap_create_handle_from_va)
352
353#define NVMAP_IOC_GUP_TEST _IOWR(NVMAP_IOC_MAGIC, 23, struct nvmap_gup_test)
354
355/* Define a label for allocation tag */
356#define NVMAP_IOC_SET_TAG_LABEL _IOW(NVMAP_IOC_MAGIC, 24, struct nvmap_set_tag_label)
357
358#define NVMAP_IOC_GET_AVAILABLE_HEAPS \
359 _IOR(NVMAP_IOC_MAGIC, 25, struct nvmap_available_heaps)
360
361#define NVMAP_IOC_GET_HEAP_SIZE \
362 _IOR(NVMAP_IOC_MAGIC, 26, struct nvmap_heap_size)
363
364/* START of T124 IOCTLS */
365/* Actually allocates memory for the specified handle, with kind */
366#define NVMAP_IOC_ALLOC_KIND _IOW(NVMAP_IOC_MAGIC, 100, struct nvmap_alloc_kind_handle)
367
368/* Actually allocates memory from IVM heaps */
369#define NVMAP_IOC_ALLOC_IVM _IOW(NVMAP_IOC_MAGIC, 101, struct nvmap_alloc_ivm_handle)
370
371/* Allocate seperate memory for VPR */
372#define NVMAP_IOC_VPR_FLOOR_SIZE _IOW(NVMAP_IOC_MAGIC, 102, __u32)
373
374#define NVMAP_IOC_MAXNR (_IOC_NR(NVMAP_IOC_VPR_FLOOR_SIZE))
375
376#endif /* __UAPI_LINUX_NVMAP_H */