diff options
author | Alex Waterman <alexw@nvidia.com> | 2017-08-17 19:51:03 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-10-13 18:19:34 -0400 |
commit | ff9c3fc20a27444cd1ff7d9402965023e425f404 (patch) | |
tree | dbb511c48a4cc0068618c8a34a69ae8305e18747 /drivers/gpu/nvgpu/include | |
parent | 59e4089278bd052b440293356605ce524e4944db (diff) |
gpu: nvgpu: Reduce usage of nvgpu_vidmem_get_page_alloc
Reduce the usage of nvgpu_vidmem_get_page_alloc() and friends as much
as possible. This reduces the dependency of nvgpu on Linux SGLs. SGLs
still need to be used, however, since sharing buffers in userspace is
done by dma_buf FD. The best way to pass the vidmem buf through the
dma_buf is by SGL pointer.
JIRA NVGPU-30
JIRA NVGPU-138
Change-Id: Ide0e9e5a557f00aa63b063be085042101a5b34ee
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1540709
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/vidmem.h | 23 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/vidmem.h | 13 |
3 files changed, 22 insertions, 16 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/linux/vidmem.h b/drivers/gpu/nvgpu/include/nvgpu/linux/vidmem.h index 76bbb05b..ec02faec 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/linux/vidmem.h +++ b/drivers/gpu/nvgpu/include/nvgpu/linux/vidmem.h | |||
@@ -24,13 +24,18 @@ struct dma_buf; | |||
24 | struct gk20a; | 24 | struct gk20a; |
25 | 25 | ||
26 | #ifdef CONFIG_GK20A_VIDMEM | 26 | #ifdef CONFIG_GK20A_VIDMEM |
27 | |||
27 | struct gk20a *nvgpu_vidmem_buf_owner(struct dma_buf *dmabuf); | 28 | struct gk20a *nvgpu_vidmem_buf_owner(struct dma_buf *dmabuf); |
28 | int nvgpu_vidmem_export_linux(struct gk20a *g, size_t bytes); | 29 | int nvgpu_vidmem_export_linux(struct gk20a *g, size_t bytes); |
29 | 30 | ||
31 | void nvgpu_vidmem_set_page_alloc(struct scatterlist *sgl, u64 addr); | ||
32 | struct nvgpu_page_alloc *nvgpu_vidmem_get_page_alloc(struct scatterlist *sgl); | ||
33 | |||
30 | int nvgpu_vidmem_buf_access_memory(struct gk20a *g, struct dma_buf *dmabuf, | 34 | int nvgpu_vidmem_buf_access_memory(struct gk20a *g, struct dma_buf *dmabuf, |
31 | void *buffer, u64 offset, u64 size, u32 cmd); | 35 | void *buffer, u64 offset, u64 size, u32 cmd); |
32 | 36 | ||
33 | #else /* !CONFIG_GK20A_VIDMEM */ | 37 | #else /* !CONFIG_GK20A_VIDMEM */ |
38 | |||
34 | static inline struct gk20a *nvgpu_vidmem_buf_owner(struct dma_buf *dmabuf) | 39 | static inline struct gk20a *nvgpu_vidmem_buf_owner(struct dma_buf *dmabuf) |
35 | { | 40 | { |
36 | return NULL; | 41 | return NULL; |
@@ -41,16 +46,28 @@ static inline int nvgpu_vidmem_export_linux(struct gk20a *g, size_t bytes) | |||
41 | return -ENOSYS; | 46 | return -ENOSYS; |
42 | } | 47 | } |
43 | 48 | ||
49 | static inline void nvgpu_vidmem_set_page_alloc(struct scatterlist *sgl, | ||
50 | u64 addr) | ||
51 | { | ||
52 | } | ||
53 | |||
54 | static inline struct nvgpu_page_alloc *nvgpu_vidmem_get_page_alloc( | ||
55 | struct scatterlist *sgl) | ||
56 | { | ||
57 | return NULL; | ||
58 | } | ||
59 | |||
44 | static inline int nvgpu_vidmem_buf_access_memory(struct gk20a *g, | 60 | static inline int nvgpu_vidmem_buf_access_memory(struct gk20a *g, |
45 | struct dma_buf *dmabuf, | 61 | struct dma_buf *dmabuf, |
46 | void *buffer, u64 offset, | 62 | void *buffer, u64 offset, |
47 | u64 size, u32 cmd) | 63 | u64 size, u32 cmd) |
48 | { | 64 | { |
49 | return -ENOSYS; | 65 | return -ENOSYS; |
50 | } | 66 | } |
51 | 67 | ||
52 | #endif | 68 | #endif |
53 | 69 | ||
70 | |||
54 | struct nvgpu_vidmem_linux { | 71 | struct nvgpu_vidmem_linux { |
55 | struct dma_buf *dmabuf; | 72 | struct dma_buf *dmabuf; |
56 | void *dmabuf_priv; | 73 | void *dmabuf_priv; |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h index 23a1bad7..537409a8 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h +++ b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h | |||
@@ -39,6 +39,7 @@ struct nvgpu_sgt; | |||
39 | struct gk20a; | 39 | struct gk20a; |
40 | struct nvgpu_allocator; | 40 | struct nvgpu_allocator; |
41 | struct nvgpu_gmmu_attrs; | 41 | struct nvgpu_gmmu_attrs; |
42 | struct nvgpu_page_alloc; | ||
42 | 43 | ||
43 | #define NVGPU_MEM_DMA_ERROR (~0ULL) | 44 | #define NVGPU_MEM_DMA_ERROR (~0ULL) |
44 | 45 | ||
@@ -162,6 +163,7 @@ struct nvgpu_mem { | |||
162 | /* | 163 | /* |
163 | * Fields only populated for vidmem allocations. | 164 | * Fields only populated for vidmem allocations. |
164 | */ | 165 | */ |
166 | struct nvgpu_page_alloc *vidmem_alloc; | ||
165 | struct nvgpu_allocator *allocator; | 167 | struct nvgpu_allocator *allocator; |
166 | struct nvgpu_list_node clear_list_entry; | 168 | struct nvgpu_list_node clear_list_entry; |
167 | 169 | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/vidmem.h b/drivers/gpu/nvgpu/include/nvgpu/vidmem.h index b89c710d..9e9f8301 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/vidmem.h +++ b/drivers/gpu/nvgpu/include/nvgpu/vidmem.h | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <nvgpu/errno.h> | 27 | #include <nvgpu/errno.h> |
28 | #include <nvgpu/nvgpu_mem.h> | 28 | #include <nvgpu/nvgpu_mem.h> |
29 | 29 | ||
30 | struct scatterlist; | ||
31 | struct work_struct; | 30 | struct work_struct; |
32 | 31 | ||
33 | struct gk20a; | 32 | struct gk20a; |
@@ -74,8 +73,6 @@ struct nvgpu_vidmem_buf *nvgpu_vidmem_user_alloc(struct gk20a *g, size_t bytes); | |||
74 | 73 | ||
75 | void nvgpu_vidmem_buf_free(struct gk20a *g, struct nvgpu_vidmem_buf *buf); | 74 | void nvgpu_vidmem_buf_free(struct gk20a *g, struct nvgpu_vidmem_buf *buf); |
76 | 75 | ||
77 | struct nvgpu_page_alloc *nvgpu_vidmem_get_page_alloc(struct scatterlist *sgl); | ||
78 | void nvgpu_vidmem_set_page_alloc(struct scatterlist *sgl, u64 addr); | ||
79 | bool nvgpu_addr_is_vidmem_page_alloc(u64 addr); | 76 | bool nvgpu_addr_is_vidmem_page_alloc(u64 addr); |
80 | int nvgpu_vidmem_get_space(struct gk20a *g, u64 *space); | 77 | int nvgpu_vidmem_get_space(struct gk20a *g, u64 *space); |
81 | 78 | ||
@@ -93,16 +90,6 @@ int nvgpu_vidmem_clear(struct gk20a *g, struct nvgpu_mem *mem); | |||
93 | * When VIDMEM support is not present this interface is used. | 90 | * When VIDMEM support is not present this interface is used. |
94 | */ | 91 | */ |
95 | 92 | ||
96 | static inline struct nvgpu_page_alloc * | ||
97 | nvgpu_vidmem_get_page_alloc(struct scatterlist *sgl) | ||
98 | { | ||
99 | return NULL; | ||
100 | } | ||
101 | |||
102 | static inline void nvgpu_vidmem_set_page_alloc(struct scatterlist *sgl, u64 addr) | ||
103 | { | ||
104 | } | ||
105 | |||
106 | static inline bool nvgpu_addr_is_vidmem_page_alloc(u64 addr) | 93 | static inline bool nvgpu_addr_is_vidmem_page_alloc(u64 addr) |
107 | { | 94 | { |
108 | return false; | 95 | return false; |