diff options
author | Alex Waterman <alexw@nvidia.com> | 2017-04-25 18:56:12 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-05-19 18:34:12 -0400 |
commit | 29cc82844e03b6f9f0e6801169b6fa0e72d56628 (patch) | |
tree | f616b6c651ce80765ee344aa33ca204c555e67f2 /drivers/gpu/nvgpu/common | |
parent | 014ace5a85f274de7debb4c6168d69c803445e19 (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/common')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_as.c | 6 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/vm.c | 14 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/vm_priv.h | 3 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/vm.c | 13 |
4 files changed, 19 insertions, 17 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_as.c b/drivers/gpu/nvgpu/common/linux/ioctl_as.c index 7a24a14f..023f8236 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_as.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_as.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <uapi/linux/nvgpu.h> | 24 | #include <uapi/linux/nvgpu.h> |
25 | 25 | ||
26 | #include <nvgpu/gmmu.h> | 26 | #include <nvgpu/gmmu.h> |
27 | #include <nvgpu/vm_area.h> | ||
27 | 28 | ||
28 | #include "gk20a/gk20a.h" | 29 | #include "gk20a/gk20a.h" |
29 | #include "gk20a/platform_gk20a.h" | 30 | #include "gk20a/platform_gk20a.h" |
@@ -56,7 +57,8 @@ static int gk20a_as_ioctl_alloc_space( | |||
56 | struct nvgpu_as_alloc_space_args *args) | 57 | struct nvgpu_as_alloc_space_args *args) |
57 | { | 58 | { |
58 | gk20a_dbg_fn(""); | 59 | gk20a_dbg_fn(""); |
59 | return gk20a_vm_alloc_space(as_share, args); | 60 | return nvgpu_vm_area_alloc(as_share->vm, args->pages, args->page_size, |
61 | &args->o_a.offset, args->flags); | ||
60 | } | 62 | } |
61 | 63 | ||
62 | static int gk20a_as_ioctl_free_space( | 64 | static int gk20a_as_ioctl_free_space( |
@@ -64,7 +66,7 @@ static int gk20a_as_ioctl_free_space( | |||
64 | struct nvgpu_as_free_space_args *args) | 66 | struct nvgpu_as_free_space_args *args) |
65 | { | 67 | { |
66 | gk20a_dbg_fn(""); | 68 | gk20a_dbg_fn(""); |
67 | return gk20a_vm_free_space(as_share, args); | 69 | return nvgpu_vm_area_free(as_share->vm, args->offset); |
68 | } | 70 | } |
69 | 71 | ||
70 | static int gk20a_as_ioctl_map_buffer_ex( | 72 | static int gk20a_as_ioctl_map_buffer_ex( |
diff --git a/drivers/gpu/nvgpu/common/linux/vm.c b/drivers/gpu/nvgpu/common/linux/vm.c index 8b9d6f96..5470d9ee 100644 --- a/drivers/gpu/nvgpu/common/linux/vm.c +++ b/drivers/gpu/nvgpu/common/linux/vm.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <nvgpu/log.h> | 20 | #include <nvgpu/log.h> |
21 | #include <nvgpu/lock.h> | 21 | #include <nvgpu/lock.h> |
22 | #include <nvgpu/rbtree.h> | 22 | #include <nvgpu/rbtree.h> |
23 | #include <nvgpu/vm_area.h> | ||
23 | #include <nvgpu/page_allocator.h> | 24 | #include <nvgpu/page_allocator.h> |
24 | 25 | ||
25 | #include "gk20a/gk20a.h" | 26 | #include "gk20a/gk20a.h" |
@@ -196,7 +197,7 @@ u64 nvgpu_vm_map(struct vm_gk20a *vm, | |||
196 | struct scatterlist *sgl; | 197 | struct scatterlist *sgl; |
197 | u64 ctag_map_win_size = 0; | 198 | u64 ctag_map_win_size = 0; |
198 | u32 ctag_map_win_ctagline = 0; | 199 | u32 ctag_map_win_ctagline = 0; |
199 | struct vm_reserved_va_node *va_node = NULL; | 200 | struct nvgpu_vm_area *vm_area = NULL; |
200 | u32 ctag_offset; | 201 | u32 ctag_offset; |
201 | enum nvgpu_aperture aperture; | 202 | enum nvgpu_aperture aperture; |
202 | 203 | ||
@@ -256,9 +257,8 @@ u64 nvgpu_vm_map(struct vm_gk20a *vm, | |||
256 | 257 | ||
257 | /* Check if we should use a fixed offset for mapping this buffer */ | 258 | /* Check if we should use a fixed offset for mapping this buffer */ |
258 | if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_FIXED_OFFSET) { | 259 | if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_FIXED_OFFSET) { |
259 | err = validate_fixed_buffer(vm, &bfr, | 260 | err = nvgpu_vm_area_validate_buffer(vm, offset_align, mapping_size, |
260 | offset_align, mapping_size, | 261 | bfr.pgsz_idx, &vm_area); |
261 | &va_node); | ||
262 | if (err) | 262 | if (err) |
263 | goto clean_up; | 263 | goto clean_up; |
264 | 264 | ||
@@ -376,10 +376,10 @@ u64 nvgpu_vm_map(struct vm_gk20a *vm, | |||
376 | if (user_mapped) | 376 | if (user_mapped) |
377 | vm->num_user_mapped_buffers++; | 377 | vm->num_user_mapped_buffers++; |
378 | 378 | ||
379 | if (va_node) { | 379 | if (vm_area) { |
380 | nvgpu_list_add_tail(&mapped_buffer->buffer_list, | 380 | nvgpu_list_add_tail(&mapped_buffer->buffer_list, |
381 | &va_node->buffer_list_head); | 381 | &vm_area->buffer_list_head); |
382 | mapped_buffer->va_node = va_node; | 382 | mapped_buffer->vm_area = vm_area; |
383 | } | 383 | } |
384 | 384 | ||
385 | nvgpu_mutex_release(&vm->update_gmmu_lock); | 385 | nvgpu_mutex_release(&vm->update_gmmu_lock); |
diff --git a/drivers/gpu/nvgpu/common/linux/vm_priv.h b/drivers/gpu/nvgpu/common/linux/vm_priv.h index 9e064d76..14852264 100644 --- a/drivers/gpu/nvgpu/common/linux/vm_priv.h +++ b/drivers/gpu/nvgpu/common/linux/vm_priv.h | |||
@@ -77,7 +77,7 @@ enum nvgpu_aperture gk20a_dmabuf_aperture(struct gk20a *g, | |||
77 | int validate_fixed_buffer(struct vm_gk20a *vm, | 77 | int validate_fixed_buffer(struct vm_gk20a *vm, |
78 | struct buffer_attrs *bfr, | 78 | struct buffer_attrs *bfr, |
79 | u64 map_offset, u64 map_size, | 79 | u64 map_offset, u64 map_size, |
80 | struct vm_reserved_va_node **pva_node); | 80 | struct nvgpu_vm_area **pva_node); |
81 | int setup_buffer_kind_and_compression(struct vm_gk20a *vm, | 81 | int setup_buffer_kind_and_compression(struct vm_gk20a *vm, |
82 | u32 flags, | 82 | u32 flags, |
83 | struct buffer_attrs *bfr, | 83 | struct buffer_attrs *bfr, |
@@ -89,6 +89,5 @@ int gk20a_alloc_comptags(struct gk20a *g, | |||
89 | u32 lines, bool user_mappable, | 89 | u32 lines, bool user_mappable, |
90 | u64 *ctag_map_win_size, | 90 | u64 *ctag_map_win_size, |
91 | u32 *ctag_map_win_ctagline); | 91 | u32 *ctag_map_win_ctagline); |
92 | void gk20a_vm_unmap_locked_kref(struct kref *ref); | ||
93 | 92 | ||
94 | #endif | 93 | #endif |
diff --git a/drivers/gpu/nvgpu/common/mm/vm.c b/drivers/gpu/nvgpu/common/mm/vm.c index 635ac0fb..3bdc905e 100644 --- a/drivers/gpu/nvgpu/common/mm/vm.c +++ b/drivers/gpu/nvgpu/common/mm/vm.c | |||
@@ -15,6 +15,7 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <nvgpu/vm.h> | 17 | #include <nvgpu/vm.h> |
18 | #include <nvgpu/vm_area.h> | ||
18 | #include <nvgpu/lock.h> | 19 | #include <nvgpu/lock.h> |
19 | #include <nvgpu/list.h> | 20 | #include <nvgpu/list.h> |
20 | #include <nvgpu/rbtree.h> | 21 | #include <nvgpu/rbtree.h> |
@@ -58,7 +59,7 @@ void nvgpu_vm_mapping_batch_finish(struct vm_gk20a *vm, | |||
58 | void nvgpu_vm_remove_support_nofree(struct vm_gk20a *vm) | 59 | void nvgpu_vm_remove_support_nofree(struct vm_gk20a *vm) |
59 | { | 60 | { |
60 | struct nvgpu_mapped_buf *mapped_buffer; | 61 | struct nvgpu_mapped_buf *mapped_buffer; |
61 | struct vm_reserved_va_node *va_node, *va_node_tmp; | 62 | struct nvgpu_vm_area *vm_area, *vm_area_tmp; |
62 | struct nvgpu_rbtree_node *node = NULL; | 63 | struct nvgpu_rbtree_node *node = NULL; |
63 | struct gk20a *g = vm->mm->g; | 64 | struct gk20a *g = vm->mm->g; |
64 | 65 | ||
@@ -86,11 +87,11 @@ void nvgpu_vm_remove_support_nofree(struct vm_gk20a *vm) | |||
86 | } | 87 | } |
87 | 88 | ||
88 | /* destroy remaining reserved memory areas */ | 89 | /* destroy remaining reserved memory areas */ |
89 | nvgpu_list_for_each_entry_safe(va_node, va_node_tmp, | 90 | nvgpu_list_for_each_entry_safe(vm_area, vm_area_tmp, |
90 | &vm->reserved_va_list, | 91 | &vm->vm_area_list, |
91 | vm_reserved_va_node, reserved_va_list) { | 92 | nvgpu_vm_area, vm_area_list) { |
92 | nvgpu_list_del(&va_node->reserved_va_list); | 93 | nvgpu_list_del(&vm_area->vm_area_list); |
93 | nvgpu_kfree(vm->mm->g, va_node); | 94 | nvgpu_kfree(vm->mm->g, vm_area); |
94 | } | 95 | } |
95 | 96 | ||
96 | nvgpu_deinit_vm(vm); | 97 | nvgpu_deinit_vm(vm); |