summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/linux/vm_priv.h
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/vm_priv.h
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/vm_priv.h')
-rw-r--r--drivers/gpu/nvgpu/common/linux/vm_priv.h102
1 files changed, 0 insertions, 102 deletions
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 @@
1/*
2 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef __COMMON_LINUX_VM_PRIV_H__
18#define __COMMON_LINUX_VM_PRIV_H__
19
20#include <nvgpu/types.h>
21
22struct sg_table;
23struct dma_buf;
24
25struct vm_gk20a;
26struct vm_gk20a_mapping_batch;
27
28struct buffer_attrs {
29 struct sg_table *sgt;
30 u64 size;
31 u64 align;
32 u32 ctag_offset;
33 u32 ctag_lines;
34 u32 ctag_allocated_lines;
35 int pgsz_idx;
36 u8 kind_v;
37 bool use_kind_v;
38 u8 uc_kind_v;
39 bool use_uc_kind_v;
40 bool ctag_user_mappable;
41};
42
43u64 nvgpu_vm_map(struct vm_gk20a *vm,
44 struct dma_buf *dmabuf,
45 u64 offset_align,
46 u32 flags,
47
48 /*
49 * compressible kind if
50 * NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL is
51 * specified, otherwise just the kind
52 */
53 s16 compr_kind,
54
55 /*
56 * incompressible kind if
57 * NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL is
58 * specified, otherwise ignored
59 */
60 s16 incompr_kind,
61
62 bool user_mapped,
63 int rw_flag,
64 u64 buffer_offset,
65 u64 mapping_size,
66 struct vm_gk20a_mapping_batch *mapping_batch);
67
68/*
69 * Notes:
70 * - Batch may be NULL if map op is not part of a batch.
71 * - If NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL is set,
72 * compr_kind and incompr_kind work as explained in nvgpu.h.
73 * - If NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL is NOT set,
74 * compr_kind holds the kind and kernel will figure out whether
75 * it is a compressible or incompressible kind. If compressible, kernel will
76 * also figure out the incompressible counterpart or return an error.
77 */
78int nvgpu_vm_map_buffer(struct vm_gk20a *vm,
79 int dmabuf_fd,
80 u64 *offset_align,
81 u32 flags, /* NVGPU_AS_MAP_BUFFER_FLAGS_ */
82 s16 compr_kind,
83 s16 incompr_kind,
84 u64 buffer_offset,
85 u64 mapping_size,
86 struct vm_gk20a_mapping_batch *batch);
87
88void nvgpu_vm_unmap(struct vm_gk20a *vm, u64 offset);
89
90/* find buffer corresponding to va */
91int nvgpu_vm_find_buf(struct vm_gk20a *vm, u64 gpu_va,
92 struct dma_buf **dmabuf,
93 u64 *offset);
94
95enum nvgpu_aperture gk20a_dmabuf_aperture(struct gk20a *g,
96 struct dma_buf *dmabuf);
97int validate_fixed_buffer(struct vm_gk20a *vm,
98 struct buffer_attrs *bfr,
99 u64 map_offset, u64 map_size,
100 struct nvgpu_vm_area **pva_node);
101
102#endif