From b3446bc0b6fca6cb992667f80a95f8503b6a652a Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Thu, 7 Sep 2017 15:27:55 -0700 Subject: gpu: nvgpu: Move dma_buf usage from mm_gk20a.c Move most of the dma_buf usage present in the mm_gk20a.c code out to Linux specific code and some commom/mm code. There's two primary groups of code: 1. dma_buf priv field code (for holding comptag data) 2. Comptag usage that relies on dma_buf pointers For (1) the dma_buf code was simply moved to common/linux/dmabuf.c since most of this code is clearly Linux specific. The comptag code was a bit more complicated since there is two parts to the comptag code. Firstly there's the code that manages the comptag memory. This is essentially a simple allocator. This was moved to common/mm/comptags.c since it can be shared across all chips. The second set of code is moved to common/linux/comptags.c since it is the interface between dma_bufs and the comptag memory. Two other fixes were done as well: - Add struct gk20a to the comptag allocator init so that the proper nvgpu_vzalloc() function could be used. - Add necessary includes to common/linux/vm_priv.h. JIRA NVGPU-30 JIRA NVGPU-138 Change-Id: I96c57f2763e5ebe18a2f2ee4b33e0e1a2597848c Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/1566628 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/gr_gk20a.c | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a/gr_gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c index 57c1c0bc..700dcdf8 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c @@ -3044,36 +3044,6 @@ out: return err; } -int gk20a_comptag_allocator_init(struct gk20a_comptag_allocator *allocator, - unsigned long size) -{ - nvgpu_mutex_init(&allocator->lock); - /* - * 0th comptag is special and is never used. The base for this bitmap - * is 1, and its size is one less than the size of comptag store. - */ - size--; - allocator->bitmap = vzalloc(BITS_TO_LONGS(size) * sizeof(long)); - if (!allocator->bitmap) - return -ENOMEM; - allocator->size = size; - return 0; -} - -void gk20a_comptag_allocator_destroy(struct gk20a_comptag_allocator *allocator) -{ - struct gr_gk20a *gr = container_of(allocator, - struct gr_gk20a, comp_tags); - - /* - * called only when exiting the driver (gk20a_remove, or unwinding the - * init stage); no users should be active, so taking the mutex is - * unnecessary here. - */ - allocator->size = 0; - nvgpu_vfree(gr->g, allocator->bitmap); -} - static void gk20a_remove_gr_support(struct gr_gk20a *gr) { struct gk20a *g = gr->g; @@ -3148,7 +3118,7 @@ static void gk20a_remove_gr_support(struct gr_gk20a *gr) nvgpu_big_free(g, gr->ctx_vars.hwpm_ctxsw_buffer_offset_map); gr->ctx_vars.hwpm_ctxsw_buffer_offset_map = NULL; - gk20a_comptag_allocator_destroy(&gr->comp_tags); + gk20a_comptag_allocator_destroy(g, &gr->comp_tags); } static int gr_gk20a_init_gr_config(struct gk20a *g, struct gr_gk20a *gr) -- cgit v1.2.2