summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/include
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2017-10-20 13:26:22 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-11-10 18:47:01 -0500
commit01c98eb68055f0b18d4f5b9dc4aa78601a00bc1e (patch)
tree535c341ede5f52165c074a860f8e4c81247e34c5 /drivers/gpu/nvgpu/include
parent8428c82c816f361ce7bbb1fe4804f350b8cbea2f (diff)
gpu: nvgpu: VM map path refactoring
Final VM mapping refactoring. Move most of the logic in the VM map path to the common/mm/vm.c code and use the generic APIs previously implemented to deal with comptags and map caching. This also updates the mapped_buffer struct to finally be free of the Linux dma_buf and scatter gather table pointers. This is replaced with the nvgpu_os_buffer struct. JIRA NVGPU-30 JIRA NVGPU-71 JIRA NVGPU-224 Change-Id: If5b32886221c3e5af2f3d7ddd4fa51dd487bb981 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1583987 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> 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/linux/vm.h5
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/vm.h53
2 files changed, 49 insertions, 9 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/linux/vm.h b/drivers/gpu/nvgpu/include/nvgpu/linux/vm.h
index 39deeb69..d9f082af 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/linux/vm.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/linux/vm.h
@@ -44,6 +44,11 @@ struct nvgpu_os_buffer {
44 struct device *dev; 44 struct device *dev;
45}; 45};
46 46
47struct nvgpu_mapped_buf_priv {
48 struct dma_buf *dmabuf;
49 struct sg_table *sgt;
50};
51
47/* NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL must be set */ 52/* NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL must be set */
48int nvgpu_vm_map_linux(struct vm_gk20a *vm, 53int nvgpu_vm_map_linux(struct vm_gk20a *vm,
49 struct dma_buf *dmabuf, 54 struct dma_buf *dmabuf,
diff --git a/drivers/gpu/nvgpu/include/nvgpu/vm.h b/drivers/gpu/nvgpu/include/nvgpu/vm.h
index b91b41e4..d501b98f 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/vm.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/vm.h
@@ -37,6 +37,18 @@ struct vm_gk20a;
37struct nvgpu_vm_area; 37struct nvgpu_vm_area;
38struct gk20a_comptag_allocator; 38struct gk20a_comptag_allocator;
39 39
40/*
41 * Defined by each OS. Allows the common VM code do things to the OS specific
42 * buffer structures.
43 */
44struct nvgpu_os_buffer;
45
46#ifdef __KERNEL__
47#include <nvgpu/linux/vm.h>
48#else
49/* QNX include goes here. */
50#endif
51
40/** 52/**
41 * This header contains the OS agnostic APIs for dealing with VMs. Most of the 53 * This header contains the OS agnostic APIs for dealing with VMs. Most of the
42 * VM implementation is system specific - it must translate from a platform's 54 * VM implementation is system specific - it must translate from a platform's
@@ -89,13 +101,12 @@ struct nvgpu_mapped_buf {
89 struct vm_gk20a *vm; 101 struct vm_gk20a *vm;
90 struct nvgpu_vm_area *vm_area; 102 struct nvgpu_vm_area *vm_area;
91 103
104 struct nvgpu_ref ref;
105
92 struct nvgpu_rbtree_node node; 106 struct nvgpu_rbtree_node node;
93 struct nvgpu_list_node buffer_list; 107 struct nvgpu_list_node buffer_list;
94 u64 addr; 108 u64 addr;
95 u64 size; 109 u64 size;
96 struct dma_buf *dmabuf;
97 struct sg_table *sgt;
98 struct nvgpu_ref ref;
99 110
100 u32 pgsz_idx; 111 u32 pgsz_idx;
101 u32 ctag_offset; 112 u32 ctag_offset;
@@ -105,13 +116,16 @@ struct nvgpu_mapped_buf {
105 u32 flags; 116 u32 flags;
106 u32 kind; 117 u32 kind;
107 bool va_allocated; 118 bool va_allocated;
108};
109 119
110/* 120 /*
111 * Defined by each OS. Allows the common VM code do things to the OS specific 121 * Separate from the nvgpu_os_buffer struct to clearly distinguish
112 * buffer structures. 122 * lifetime. A nvgpu_mapped_buf_priv will _always_ be wrapped by a
113 */ 123 * struct nvgpu_mapped_buf; however, there are times when a struct
114struct nvgpu_os_buffer; 124 * nvgpu_os_buffer would be separate. This aims to prevent dangerous
125 * usage of container_of() or the like in OS code.
126 */
127 struct nvgpu_mapped_buf_priv os_priv;
128};
115 129
116static inline struct nvgpu_mapped_buf * 130static inline struct nvgpu_mapped_buf *
117nvgpu_mapped_buf_from_buffer_list(struct nvgpu_list_node *node) 131nvgpu_mapped_buf_from_buffer_list(struct nvgpu_list_node *node)
@@ -226,6 +240,25 @@ void nvgpu_vm_put_buffers(struct vm_gk20a *vm,
226 struct nvgpu_mapped_buf **mapped_buffers, 240 struct nvgpu_mapped_buf **mapped_buffers,
227 int num_buffers); 241 int num_buffers);
228 242
243struct nvgpu_mapped_buf *nvgpu_vm_find_mapping(struct vm_gk20a *vm,
244 struct nvgpu_os_buffer *os_buf,
245 u64 map_addr,
246 u32 flags,
247 int kind);
248
249struct nvgpu_mapped_buf *nvgpu_vm_map(struct vm_gk20a *vm,
250 struct nvgpu_os_buffer *os_buf,
251 struct nvgpu_sgt *sgt,
252 u64 map_addr,
253 u64 map_size,
254 u64 phys_offset,
255 int rw,
256 u32 flags,
257 s16 compr_kind,
258 s16 incompr_kind,
259 struct vm_gk20a_mapping_batch *batch,
260 enum nvgpu_aperture aperture);
261
229void nvgpu_vm_unmap(struct vm_gk20a *vm, u64 offset, 262void nvgpu_vm_unmap(struct vm_gk20a *vm, u64 offset,
230 struct vm_gk20a_mapping_batch *batch); 263 struct vm_gk20a_mapping_batch *batch);
231 264
@@ -240,6 +273,8 @@ void nvgpu_vm_unmap_system(struct nvgpu_mapped_buf *mapped_buffer);
240 */ 273 */
241void __nvgpu_vm_unmap_ref(struct nvgpu_ref *ref); 274void __nvgpu_vm_unmap_ref(struct nvgpu_ref *ref);
242 275
276u64 nvgpu_os_buf_get_size(struct nvgpu_os_buffer *os_buf);
277
243/* 278/*
244 * These all require the VM update lock to be held. 279 * These all require the VM update lock to be held.
245 */ 280 */