From 0c5d0c6a9ef0e33f01ce1485674bb2271e4bb580 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Thu, 12 Oct 2017 16:19:55 -0700 Subject: gpu: nvgpu: Begin reorganizing VM mapping/unmapping Move vm_priv.h to 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 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_() 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 Reviewed-on: https://git-master.nvidia.com/r/1578896 GVS: Gerrit_Virtual_Submit Reviewed-by: David Martinez Nieto Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/common/linux/vm_priv.h | 102 ------------------------------- 1 file changed, 102 deletions(-) delete mode 100644 drivers/gpu/nvgpu/common/linux/vm_priv.h (limited to 'drivers/gpu/nvgpu/common/linux/vm_priv.h') diff --git a/drivers/gpu/nvgpu/common/linux/vm_priv.h b/drivers/gpu/nvgpu/common/linux/vm_priv.h deleted file mode 100644 index be7efa8b..00000000 --- a/drivers/gpu/nvgpu/common/linux/vm_priv.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef __COMMON_LINUX_VM_PRIV_H__ -#define __COMMON_LINUX_VM_PRIV_H__ - -#include - -struct sg_table; -struct dma_buf; - -struct vm_gk20a; -struct vm_gk20a_mapping_batch; - -struct buffer_attrs { - struct sg_table *sgt; - u64 size; - u64 align; - u32 ctag_offset; - u32 ctag_lines; - u32 ctag_allocated_lines; - int pgsz_idx; - u8 kind_v; - bool use_kind_v; - u8 uc_kind_v; - bool use_uc_kind_v; - bool ctag_user_mappable; -}; - -u64 nvgpu_vm_map(struct vm_gk20a *vm, - struct dma_buf *dmabuf, - u64 offset_align, - u32 flags, - - /* - * compressible kind if - * NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL is - * specified, otherwise just the kind - */ - s16 compr_kind, - - /* - * incompressible kind if - * NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL is - * specified, otherwise ignored - */ - s16 incompr_kind, - - bool user_mapped, - int rw_flag, - u64 buffer_offset, - u64 mapping_size, - struct vm_gk20a_mapping_batch *mapping_batch); - -/* - * Notes: - * - Batch may be NULL if map op is not part of a batch. - * - If NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL is set, - * compr_kind and incompr_kind work as explained in nvgpu.h. - * - If NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL is NOT set, - * compr_kind holds the kind and kernel will figure out whether - * it is a compressible or incompressible kind. If compressible, kernel will - * also figure out the incompressible counterpart or return an error. - */ -int nvgpu_vm_map_buffer(struct vm_gk20a *vm, - int dmabuf_fd, - u64 *offset_align, - u32 flags, /* NVGPU_AS_MAP_BUFFER_FLAGS_ */ - s16 compr_kind, - s16 incompr_kind, - u64 buffer_offset, - u64 mapping_size, - struct vm_gk20a_mapping_batch *batch); - -void nvgpu_vm_unmap(struct vm_gk20a *vm, u64 offset); - -/* find buffer corresponding to va */ -int nvgpu_vm_find_buf(struct vm_gk20a *vm, u64 gpu_va, - struct dma_buf **dmabuf, - u64 *offset); - -enum nvgpu_aperture gk20a_dmabuf_aperture(struct gk20a *g, - struct dma_buf *dmabuf); -int validate_fixed_buffer(struct vm_gk20a *vm, - struct buffer_attrs *bfr, - u64 map_offset, u64 map_size, - struct nvgpu_vm_area **pva_node); - -#endif -- cgit v1.2.2