summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/include
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2017-07-31 15:32:07 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-10-10 11:01:04 -0400
commit3c37701377459fbea2b460e1b9c65a863dfb04b2 (patch)
tree60a57a260dc8bcbd81089af8e9e966074e3bc881 /drivers/gpu/nvgpu/include
parentb61306795b53647e8d1d4279417df1e1fe0f4b86 (diff)
gpu: nvgpu: Split VIDMEM support from mm_gk20a.c
Split VIDMEM support into its own code files organized as such: common/mm/vidmem.c - Base vidmem support common/linux/vidmem.c - Linux specific user-space interaction include/nvgpu/vidmem.h - Vidmem API definitions Also use the config to enable/disable VIDMEM support in the makefile and remove as many CONFIG_GK20A_VIDMEM preprocessor checks as possible from the source code. And lastly update a while-loop that iterated over an SGT to use the new for_each construct for iterating over SGTs. Currently this organization is not perfectly adhered to. More patches will fix that. JIRA NVGPU-30 JIRA NVGPU-138 Change-Id: Ic0f4d2cf38b65849c7dc350a69b175421477069c Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1540705 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/vidmem.h139
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
29struct scatterlist;
30struct dma_buf;
31struct work_struct;
32
33struct gk20a;
34struct mm_gk20a;
35struct nvgpu_mem;
36
37struct 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
47struct nvgpu_page_alloc *get_vidmem_page_alloc(struct scatterlist *sgl);
48void set_vidmem_page_alloc(struct scatterlist *sgl, u64 addr);
49bool is_vidmem_page_alloc(u64 addr);
50int gk20a_vidmem_buf_alloc(struct gk20a *g, size_t bytes);
51int gk20a_vidmem_get_space(struct gk20a *g, u64 *space);
52
53struct nvgpu_mem *get_pending_mem_desc(struct mm_gk20a *mm);
54
55void gk20a_vidmem_destroy(struct gk20a *g);
56int gk20a_init_vidmem(struct mm_gk20a *mm);
57int gk20a_vidmem_clear_all(struct gk20a *g);
58
59void gk20a_vidmem_clear_mem_worker(struct work_struct *work);
60int 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 */
65struct gk20a *gk20a_vidmem_buf_owner(struct dma_buf *dmabuf);
66int 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
75static inline struct nvgpu_page_alloc *
76get_vidmem_page_alloc(struct scatterlist *sgl)
77{
78 return NULL;
79}
80
81static inline void set_vidmem_page_alloc(struct scatterlist *sgl, u64 addr)
82{
83}
84
85static inline bool is_vidmem_page_alloc(u64 addr)
86{
87 return false;
88}
89
90static inline int gk20a_vidmem_buf_alloc(struct gk20a *g, size_t bytes)
91{
92 return -ENOSYS;
93}
94static inline int gk20a_vidmem_get_space(struct gk20a *g, u64 *space)
95{
96 return -ENOSYS;
97}
98
99static inline struct nvgpu_mem *get_pending_mem_desc(struct mm_gk20a *mm)
100{
101 return NULL;
102}
103
104static inline void gk20a_vidmem_destroy(struct gk20a *g)
105{
106}
107
108static inline int gk20a_init_vidmem(struct mm_gk20a *mm)
109{
110 return 0;
111}
112
113static inline int gk20a_vidmem_clear_all(struct gk20a *g)
114{
115 return -ENOSYS;
116}
117
118static inline int gk20a_gmmu_clear_vidmem_mem(struct gk20a *g,
119 struct nvgpu_mem *mem)
120{
121 return -ENOSYS;
122}
123
124static inline struct gk20a *gk20a_vidmem_buf_owner(struct dma_buf *dmabuf)
125{
126 return NULL;
127}
128
129static 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__ */