summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/include/nvgpu/vm_area.h
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2017-04-25 18:56:12 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-05-19 18:34:12 -0400
commit29cc82844e03b6f9f0e6801169b6fa0e72d56628 (patch)
treef616b6c651ce80765ee344aa33ca204c555e67f2 /drivers/gpu/nvgpu/include/nvgpu/vm_area.h
parent014ace5a85f274de7debb4c6168d69c803445e19 (diff)
gpu: nvgpu: Split vm_area management into vm code
The vm_reserve_va_node struct is essentially a special VM area that can be used for sparse mappings and fixed mappings. The name of this struct is somewhat confusing (as node is typically used for list items). Though this struct is a part of a list it doesn't really make sense to call this a list item since it's much more. Based on that the struct has been renamed to nvgpu_vm_area to capture the actual use of the struct more accurately. This also moves all of the management code of vm areas to a new file devoted solely to vm_area management. Also add a brief overview of the VM architecture. This should help other people follow along the hierachy of ownership and lifetimes in the rather complex MM code. JIRA NVGPU-12 JIRA NVGPU-30 Change-Id: If85e1cf868031d0dc265e7bed50b58a2aed2602e Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: http://git-master/r/1477744 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/include/nvgpu/vm_area.h')
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/vm_area.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/vm_area.h b/drivers/gpu/nvgpu/include/nvgpu/vm_area.h
new file mode 100644
index 00000000..ffe4b99b
--- /dev/null
+++ b/drivers/gpu/nvgpu/include/nvgpu/vm_area.h
@@ -0,0 +1,63 @@
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 __NVGPU_VM_AREA_H__
18#define __NVGPU_VM_AREA_H__
19
20#include <nvgpu/list.h>
21#include <nvgpu/types.h>
22
23struct vm_gk20a;
24struct gk20a_as_share;
25struct nvgpu_as_alloc_space_args;
26struct nvgpu_as_free_space_args;
27
28struct nvgpu_vm_area {
29 /*
30 * Entry into the list of VM areas owned by a VM.
31 */
32 struct nvgpu_list_node vm_area_list;
33
34 /*
35 * List of buffers mapped into this vm_area.
36 */
37 struct nvgpu_list_node buffer_list_head;
38
39 u32 flags;
40 u32 pgsz_idx;
41 u64 addr;
42 u64 size;
43 bool sparse;
44};
45
46static inline struct nvgpu_vm_area *
47nvgpu_vm_area_from_vm_area_list(struct nvgpu_list_node *node)
48{
49 return (struct nvgpu_vm_area *)
50 ((uintptr_t)node - offsetof(struct nvgpu_vm_area,
51 vm_area_list));
52};
53
54int nvgpu_vm_area_alloc(struct vm_gk20a *vm, u32 pages, u32 page_size,
55 u64 *addr, u32 flags);
56int nvgpu_vm_area_free(struct vm_gk20a *vm, u64 addr);
57
58struct nvgpu_vm_area *nvgpu_vm_area_find(struct vm_gk20a *vm, u64 addr);
59int nvgpu_vm_area_validate_buffer(struct vm_gk20a *vm,
60 u64 map_offset, u64 map_size, int pgsz_idx,
61 struct nvgpu_vm_area **pvm_area);
62
63#endif