diff options
Diffstat (limited to 'drivers/gpu/nvgpu/include')
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/vidmem.h | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/vidmem.h b/drivers/gpu/nvgpu/include/nvgpu/vidmem.h new file mode 100644 index 00000000..a5d0ae11 --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/vidmem.h | |||
@@ -0,0 +1,139 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, 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 | #ifndef __NVGPU_VIDMEM_H__ | ||
24 | #define __NVGPU_VIDMEM_H__ | ||
25 | |||
26 | #include <nvgpu/types.h> | ||
27 | #include <nvgpu/errno.h> | ||
28 | |||
29 | struct scatterlist; | ||
30 | struct dma_buf; | ||
31 | struct work_struct; | ||
32 | |||
33 | struct gk20a; | ||
34 | struct mm_gk20a; | ||
35 | struct nvgpu_mem; | ||
36 | |||
37 | struct gk20a_vidmem_buf { | ||
38 | struct gk20a *g; | ||
39 | struct nvgpu_mem *mem; | ||
40 | struct dma_buf *dmabuf; | ||
41 | void *dmabuf_priv; | ||
42 | void (*dmabuf_priv_delete)(void *); | ||
43 | }; | ||
44 | |||
45 | #if defined(CONFIG_GK20A_VIDMEM) | ||
46 | |||
47 | struct nvgpu_page_alloc *get_vidmem_page_alloc(struct scatterlist *sgl); | ||
48 | void set_vidmem_page_alloc(struct scatterlist *sgl, u64 addr); | ||
49 | bool is_vidmem_page_alloc(u64 addr); | ||
50 | int gk20a_vidmem_buf_alloc(struct gk20a *g, size_t bytes); | ||
51 | int gk20a_vidmem_get_space(struct gk20a *g, u64 *space); | ||
52 | |||
53 | struct nvgpu_mem *get_pending_mem_desc(struct mm_gk20a *mm); | ||
54 | |||
55 | void gk20a_vidmem_destroy(struct gk20a *g); | ||
56 | int gk20a_init_vidmem(struct mm_gk20a *mm); | ||
57 | int gk20a_vidmem_clear_all(struct gk20a *g); | ||
58 | |||
59 | void gk20a_vidmem_clear_mem_worker(struct work_struct *work); | ||
60 | int gk20a_gmmu_clear_vidmem_mem(struct gk20a *g, struct nvgpu_mem *mem); | ||
61 | |||
62 | /* | ||
63 | * Will need to be moved later on once we have the Linux vidmem.h file. | ||
64 | */ | ||
65 | struct gk20a *gk20a_vidmem_buf_owner(struct dma_buf *dmabuf); | ||
66 | int gk20a_vidbuf_access_memory(struct gk20a *g, struct dma_buf *dmabuf, | ||
67 | void *buffer, u64 offset, u64 size, u32 cmd); | ||
68 | |||
69 | #else /* !defined(CONFIG_GK20A_VIDMEM) */ | ||
70 | |||
71 | /* | ||
72 | * When VIDMEM support is not present this interface is used. | ||
73 | */ | ||
74 | |||
75 | static inline struct nvgpu_page_alloc * | ||
76 | get_vidmem_page_alloc(struct scatterlist *sgl) | ||
77 | { | ||
78 | return NULL; | ||
79 | } | ||
80 | |||
81 | static inline void set_vidmem_page_alloc(struct scatterlist *sgl, u64 addr) | ||
82 | { | ||
83 | } | ||
84 | |||
85 | static inline bool is_vidmem_page_alloc(u64 addr) | ||
86 | { | ||
87 | return false; | ||
88 | } | ||
89 | |||
90 | static inline int gk20a_vidmem_buf_alloc(struct gk20a *g, size_t bytes) | ||
91 | { | ||
92 | return -ENOSYS; | ||
93 | } | ||
94 | static inline int gk20a_vidmem_get_space(struct gk20a *g, u64 *space) | ||
95 | { | ||
96 | return -ENOSYS; | ||
97 | } | ||
98 | |||
99 | static inline struct nvgpu_mem *get_pending_mem_desc(struct mm_gk20a *mm) | ||
100 | { | ||
101 | return NULL; | ||
102 | } | ||
103 | |||
104 | static inline void gk20a_vidmem_destroy(struct gk20a *g) | ||
105 | { | ||
106 | } | ||
107 | |||
108 | static inline int gk20a_init_vidmem(struct mm_gk20a *mm) | ||
109 | { | ||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | static inline int gk20a_vidmem_clear_all(struct gk20a *g) | ||
114 | { | ||
115 | return -ENOSYS; | ||
116 | } | ||
117 | |||
118 | static inline int gk20a_gmmu_clear_vidmem_mem(struct gk20a *g, | ||
119 | struct nvgpu_mem *mem) | ||
120 | { | ||
121 | return -ENOSYS; | ||
122 | } | ||
123 | |||
124 | static inline struct gk20a *gk20a_vidmem_buf_owner(struct dma_buf *dmabuf) | ||
125 | { | ||
126 | return NULL; | ||
127 | } | ||
128 | |||
129 | static inline int gk20a_vidbuf_access_memory(struct gk20a *g, | ||
130 | struct dma_buf *dmabuf, | ||
131 | void *buffer, u64 offset, | ||
132 | u64 size, u32 cmd) | ||
133 | { | ||
134 | return -ENOSYS; | ||
135 | } | ||
136 | |||
137 | #endif /* !defined(CONFIG_GK20A_VIDMEM) */ | ||
138 | |||
139 | #endif /* __NVGPU_VIDMEM_H__ */ | ||