From ff9c3fc20a27444cd1ff7d9402965023e425f404 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Thu, 17 Aug 2017 16:51:03 -0700 Subject: 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 Reviewed-on: https://git-master.nvidia.com/r/1540709 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/include/nvgpu/linux/vidmem.h | 23 ++++++++++++++++++++--- drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h | 2 ++ drivers/gpu/nvgpu/include/nvgpu/vidmem.h | 13 ------------- 3 files changed, 22 insertions(+), 16 deletions(-) (limited to 'drivers/gpu/nvgpu/include') 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; struct gk20a; #ifdef CONFIG_GK20A_VIDMEM + struct gk20a *nvgpu_vidmem_buf_owner(struct dma_buf *dmabuf); int nvgpu_vidmem_export_linux(struct gk20a *g, size_t bytes); +void nvgpu_vidmem_set_page_alloc(struct scatterlist *sgl, u64 addr); +struct nvgpu_page_alloc *nvgpu_vidmem_get_page_alloc(struct scatterlist *sgl); + int nvgpu_vidmem_buf_access_memory(struct gk20a *g, struct dma_buf *dmabuf, void *buffer, u64 offset, u64 size, u32 cmd); #else /* !CONFIG_GK20A_VIDMEM */ + static inline struct gk20a *nvgpu_vidmem_buf_owner(struct dma_buf *dmabuf) { return NULL; @@ -41,16 +46,28 @@ static inline int nvgpu_vidmem_export_linux(struct gk20a *g, size_t bytes) return -ENOSYS; } +static inline void nvgpu_vidmem_set_page_alloc(struct scatterlist *sgl, + u64 addr) +{ +} + +static inline struct nvgpu_page_alloc *nvgpu_vidmem_get_page_alloc( + struct scatterlist *sgl) +{ + return NULL; +} + static inline int nvgpu_vidmem_buf_access_memory(struct gk20a *g, - struct dma_buf *dmabuf, - void *buffer, u64 offset, - u64 size, u32 cmd) + struct dma_buf *dmabuf, + void *buffer, u64 offset, + u64 size, u32 cmd) { return -ENOSYS; } #endif + struct nvgpu_vidmem_linux { struct dma_buf *dmabuf; 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; struct gk20a; struct nvgpu_allocator; struct nvgpu_gmmu_attrs; +struct nvgpu_page_alloc; #define NVGPU_MEM_DMA_ERROR (~0ULL) @@ -162,6 +163,7 @@ struct nvgpu_mem { /* * Fields only populated for vidmem allocations. */ + struct nvgpu_page_alloc *vidmem_alloc; struct nvgpu_allocator *allocator; struct nvgpu_list_node clear_list_entry; 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 @@ #include #include -struct scatterlist; struct work_struct; struct gk20a; @@ -74,8 +73,6 @@ struct nvgpu_vidmem_buf *nvgpu_vidmem_user_alloc(struct gk20a *g, size_t bytes); void nvgpu_vidmem_buf_free(struct gk20a *g, struct nvgpu_vidmem_buf *buf); -struct nvgpu_page_alloc *nvgpu_vidmem_get_page_alloc(struct scatterlist *sgl); -void nvgpu_vidmem_set_page_alloc(struct scatterlist *sgl, u64 addr); bool nvgpu_addr_is_vidmem_page_alloc(u64 addr); int nvgpu_vidmem_get_space(struct gk20a *g, u64 *space); @@ -93,16 +90,6 @@ int nvgpu_vidmem_clear(struct gk20a *g, struct nvgpu_mem *mem); * When VIDMEM support is not present this interface is used. */ -static inline struct nvgpu_page_alloc * -nvgpu_vidmem_get_page_alloc(struct scatterlist *sgl) -{ - return NULL; -} - -static inline void nvgpu_vidmem_set_page_alloc(struct scatterlist *sgl, u64 addr) -{ -} - static inline bool nvgpu_addr_is_vidmem_page_alloc(u64 addr) { return false; -- cgit v1.2.2