summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/linux/cde.c
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2017-10-12 19:19:55 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-10-24 18:16:50 -0400
commit0c5d0c6a9ef0e33f01ce1485674bb2271e4bb580 (patch)
tree15ce6b6d41decce809e62c996be94492263daede /drivers/gpu/nvgpu/common/linux/cde.c
parent2a285d0607a20694476399f5719e74dbc26fcd58 (diff)
gpu: nvgpu: Begin reorganizing VM mapping/unmapping
Move vm_priv.h to <nvgpu/linux/vm.h> and rename nvgpu_vm_map() to nvgpu_vm_map_linux(). Also remove a redundant unmap function from the unmap path. These changes are the beginning of reworking the nvgpu Linux mapping and unmapping code. The rest of this patch is just the necessary changes to use the new map function naming and the new path to the Linux vm header. Patch Series Goal ----------------- There's two major goals for this patch series. Note that these goals are not achieved in this patch. There will be subsequent patches. 1. Remove all last vestiges of Linux code from common/mm/vm.c 2. Implement map caching in the common/mm/vm.c code To accomplish this firstly the VM mapping code needs to have the struct nvgpu_mapped_buf data struct be completely Linux free. That means implementing an abstraction for this to hold the Linux stuff that mapped buffers carry about (SGT, dma_buf). This is why the vm_priv.h code has been moved: it will need to be included by the <nvgpu/vm.h> header so that the OS specific struct can be pulled into struct nvgpu_mapped_buf. Next renaming the nvgpu_vm_map() to nvgpu_vm_map_linux() is in preparation for adding a new nvgpu_vm_map() that handles the map caching with nvgpu_mapped_buf. The mapping code is fairly straight forward: nvgpu_vm_map does OS generic stuff; each OS then calls this function from an nvgpu_vm_map_<OS>() or the like that does any OS specific adjustments/management. Freeing buffers is much more tricky however. The maps are all reference counted since userspace does not track buffers and expects us to handle this instead. Ugh! Since there's ref-counts the free code will require a callback into the OS specific code since the OS specific code cannot free a buffer directly. THis make's the path for freeing a buffer quite convoluted. JIRA NVGPU-30 JIRA NVGPU-71 Change-Id: I5e0975f60663a0d6cf0a6bd90e099f51e02c2395 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1578896 GVS: Gerrit_Virtual_Submit Reviewed-by: David Martinez Nieto <dmartineznie@nvidia.com> Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/cde.c')
-rw-r--r--drivers/gpu/nvgpu/common/linux/cde.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/cde.c b/drivers/gpu/nvgpu/common/linux/cde.c
index 577d86e8..30edc1d5 100644
--- a/drivers/gpu/nvgpu/common/linux/cde.c
+++ b/drivers/gpu/nvgpu/common/linux/cde.c
@@ -31,6 +31,8 @@
31#include <nvgpu/bug.h> 31#include <nvgpu/bug.h>
32#include <nvgpu/firmware.h> 32#include <nvgpu/firmware.h>
33 33
34#include <nvgpu/linux/vm.h>
35
34#include "gk20a/gk20a.h" 36#include "gk20a/gk20a.h"
35#include "gk20a/channel_gk20a.h" 37#include "gk20a/channel_gk20a.h"
36#include "gk20a/mm_gk20a.h" 38#include "gk20a/mm_gk20a.h"
@@ -44,12 +46,6 @@
44#include <nvgpu/hw/gk20a/hw_ccsr_gk20a.h> 46#include <nvgpu/hw/gk20a/hw_ccsr_gk20a.h>
45#include <nvgpu/hw/gk20a/hw_pbdma_gk20a.h> 47#include <nvgpu/hw/gk20a/hw_pbdma_gk20a.h>
46 48
47/*
48 * Currently this code uses nvgpu_vm_map() since it takes dmabuf FDs from the
49 * CDE ioctls. That has to change - instead this needs to take an nvgpu_mem.
50 */
51#include "common/linux/vm_priv.h"
52
53static int gk20a_cde_load(struct gk20a_cde_ctx *cde_ctx); 49static int gk20a_cde_load(struct gk20a_cde_ctx *cde_ctx);
54static struct gk20a_cde_ctx *gk20a_cde_allocate_context(struct nvgpu_os_linux *l); 50static struct gk20a_cde_ctx *gk20a_cde_allocate_context(struct nvgpu_os_linux *l);
55 51
@@ -1052,8 +1048,8 @@ __releases(&l->cde_app->mutex)
1052 1048
1053 1049
1054 /* map the destination buffer */ 1050 /* map the destination buffer */
1055 get_dma_buf(compbits_scatter_buf); /* a ref for nvgpu_vm_map */ 1051 get_dma_buf(compbits_scatter_buf); /* a ref for nvgpu_vm_map_linux */
1056 map_vaddr = nvgpu_vm_map(cde_ctx->vm, compbits_scatter_buf, 0, 1052 map_vaddr = nvgpu_vm_map_linux(cde_ctx->vm, compbits_scatter_buf, 0,
1057 NVGPU_AS_MAP_BUFFER_FLAGS_CACHEABLE | 1053 NVGPU_AS_MAP_BUFFER_FLAGS_CACHEABLE |
1058 NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL, 1054 NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL,
1059 NV_KIND_INVALID, 1055 NV_KIND_INVALID,