From 29cc82844e03b6f9f0e6801169b6fa0e72d56628 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Tue, 25 Apr 2017 15:56:12 -0700 Subject: 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 Reviewed-on: http://git-master/r/1477744 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/ioctl_as.c | 6 ++++-- drivers/gpu/nvgpu/common/linux/vm.c | 14 +++++++------- drivers/gpu/nvgpu/common/linux/vm_priv.h | 3 +-- drivers/gpu/nvgpu/common/mm/vm.c | 13 +++++++------ 4 files changed, 19 insertions(+), 17 deletions(-) (limited to 'drivers/gpu/nvgpu/common') 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 @@ #include #include +#include #include "gk20a/gk20a.h" #include "gk20a/platform_gk20a.h" @@ -56,7 +57,8 @@ static int gk20a_as_ioctl_alloc_space( struct nvgpu_as_alloc_space_args *args) { gk20a_dbg_fn(""); - return gk20a_vm_alloc_space(as_share, args); + return nvgpu_vm_area_alloc(as_share->vm, args->pages, args->page_size, + &args->o_a.offset, args->flags); } static int gk20a_as_ioctl_free_space( @@ -64,7 +66,7 @@ static int gk20a_as_ioctl_free_space( struct nvgpu_as_free_space_args *args) { gk20a_dbg_fn(""); - return gk20a_vm_free_space(as_share, args); + return nvgpu_vm_area_free(as_share->vm, args->offset); } 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 @@ #include #include #include +#include #include #include "gk20a/gk20a.h" @@ -196,7 +197,7 @@ u64 nvgpu_vm_map(struct vm_gk20a *vm, struct scatterlist *sgl; u64 ctag_map_win_size = 0; u32 ctag_map_win_ctagline = 0; - struct vm_reserved_va_node *va_node = NULL; + struct nvgpu_vm_area *vm_area = NULL; u32 ctag_offset; enum nvgpu_aperture aperture; @@ -256,9 +257,8 @@ u64 nvgpu_vm_map(struct vm_gk20a *vm, /* Check if we should use a fixed offset for mapping this buffer */ if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_FIXED_OFFSET) { - err = validate_fixed_buffer(vm, &bfr, - offset_align, mapping_size, - &va_node); + err = nvgpu_vm_area_validate_buffer(vm, offset_align, mapping_size, + bfr.pgsz_idx, &vm_area); if (err) goto clean_up; @@ -376,10 +376,10 @@ u64 nvgpu_vm_map(struct vm_gk20a *vm, if (user_mapped) vm->num_user_mapped_buffers++; - if (va_node) { + if (vm_area) { nvgpu_list_add_tail(&mapped_buffer->buffer_list, - &va_node->buffer_list_head); - mapped_buffer->va_node = va_node; + &vm_area->buffer_list_head); + mapped_buffer->vm_area = vm_area; } 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, int validate_fixed_buffer(struct vm_gk20a *vm, struct buffer_attrs *bfr, u64 map_offset, u64 map_size, - struct vm_reserved_va_node **pva_node); + struct nvgpu_vm_area **pva_node); int setup_buffer_kind_and_compression(struct vm_gk20a *vm, u32 flags, struct buffer_attrs *bfr, @@ -89,6 +89,5 @@ int gk20a_alloc_comptags(struct gk20a *g, u32 lines, bool user_mappable, u64 *ctag_map_win_size, u32 *ctag_map_win_ctagline); -void gk20a_vm_unmap_locked_kref(struct kref *ref); #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 @@ */ #include +#include #include #include #include @@ -58,7 +59,7 @@ void nvgpu_vm_mapping_batch_finish(struct vm_gk20a *vm, void nvgpu_vm_remove_support_nofree(struct vm_gk20a *vm) { struct nvgpu_mapped_buf *mapped_buffer; - struct vm_reserved_va_node *va_node, *va_node_tmp; + struct nvgpu_vm_area *vm_area, *vm_area_tmp; struct nvgpu_rbtree_node *node = NULL; struct gk20a *g = vm->mm->g; @@ -86,11 +87,11 @@ void nvgpu_vm_remove_support_nofree(struct vm_gk20a *vm) } /* destroy remaining reserved memory areas */ - nvgpu_list_for_each_entry_safe(va_node, va_node_tmp, - &vm->reserved_va_list, - vm_reserved_va_node, reserved_va_list) { - nvgpu_list_del(&va_node->reserved_va_list); - nvgpu_kfree(vm->mm->g, va_node); + nvgpu_list_for_each_entry_safe(vm_area, vm_area_tmp, + &vm->vm_area_list, + nvgpu_vm_area, vm_area_list) { + nvgpu_list_del(&vm_area->vm_area_list); + nvgpu_kfree(vm->mm->g, vm_area); } nvgpu_deinit_vm(vm); -- cgit v1.2.2