summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/mm_gk20a.h
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2015-06-17 13:31:08 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-01-31 19:23:07 -0500
commitd630f1d99f60b1c2ec87506a2738bac4d1895b07 (patch)
tree5b9cad58f585424a64e7b675d503a87bbcada254 /drivers/gpu/nvgpu/gk20a/mm_gk20a.h
parent793791ebb7ddbb34f0aaf3e300b24ed24aa76661 (diff)
gpu: nvgpu: Unify the small and large page address spaces
The basic structure of this patch is to make the small page allocator and the large page allocator into pointers (where they used to be just structs). Then assign each of those pointers to the same actual allocator since the buddy allocator has supported mixed page sizes since its inception. For the rest of the driver some changes had to be made in order to actually support mixed pages in a single address space. 1. Unifying the allocation page size determination Since the allocation and map operations happen at distinct times both mapping and allocation of GVA space must agree on page size. This is because the allocation has to separate allocations into separate PDEs to avoid the necessity of supporting mixed PDEs. To this end a function __get_pte_size() was introduced which is used both by the balloc code and the core GPU MM code. It determines page size based only on the length of the mapping/ allocation. 2. Fixed address allocation + page size Similar to regular mappings/GVA allocations fixed address mapping page size determination had to be modified. In the past the address of the mapping determined page size since the address space split was by address (low addresses were small pages, high addresses large pages). Since that is no longer the case the page size field in the reserve memory ioctl is now honored by the mapping code. When, for instance, CUDA makes a memory reservation it specifies small or large pages. When CUDA requests mappings to be made within that address range the page size is then looked up in the reserved memory struct. Fixed address reservations were also modified to now always allocate at a PDE granularity (64M or 128M depending on large page size. This prevents non-fixed allocations from ending up in the same PDE and causing kernel panics or GMMU faults. 3. The rest... The rest of the changes are just by products of the above. Lots of places required minor updates to use a pointer to the GVA allocator struct instead of the struct itself. Lastly, this change is not truly complete. More work remains to be done in order to fully remove the notion that there was such a thing as separate address spaces for different page sizes. Basically after this patch what remains is cleanup and proper documentation. Bug 1396644 Bug 1729947 Change-Id: If51ab396a37ba16c69e434adb47edeef083dce57 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: http://git-master/r/1265300 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/mm_gk20a.h')
-rw-r--r--drivers/gpu/nvgpu/gk20a/mm_gk20a.h60
1 files changed, 30 insertions, 30 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h
index 5ef8ae25..394d1d25 100644
--- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h
@@ -270,11 +270,13 @@ struct vm_gk20a {
270 270
271 struct gk20a_mm_entry pdb; 271 struct gk20a_mm_entry pdb;
272 272
273 struct nvgpu_allocator vma[gmmu_nr_page_sizes];
274
275 /* If necessary, split fixed from non-fixed. */ 273 /* If necessary, split fixed from non-fixed. */
276 struct nvgpu_allocator fixed; 274 struct nvgpu_allocator fixed;
277 275
276 struct nvgpu_allocator *vma[gmmu_nr_page_sizes];
277 struct nvgpu_allocator kernel;
278 struct nvgpu_allocator user;
279
278 struct rb_root mapped_buffers; 280 struct rb_root mapped_buffers;
279 281
280 struct list_head reserved_va_list; 282 struct list_head reserved_va_list;
@@ -425,7 +427,7 @@ static inline int bar1_aperture_size_mb_gk20a(void)
425 return 16; /* 16MB is more than enough atm. */ 427 return 16; /* 16MB is more than enough atm. */
426} 428}
427 429
428/*The maximum GPU VA range supported */ 430/* The maximum GPU VA range supported */
429#define NV_GMMU_VA_RANGE 38 431#define NV_GMMU_VA_RANGE 38
430 432
431/* The default userspace-visible GPU VA size */ 433/* The default userspace-visible GPU VA size */
@@ -434,43 +436,39 @@ static inline int bar1_aperture_size_mb_gk20a(void)
434/* The default kernel-reserved GPU VA size */ 436/* The default kernel-reserved GPU VA size */
435#define NV_MM_DEFAULT_KERNEL_SIZE (1ULL << 32) 437#define NV_MM_DEFAULT_KERNEL_SIZE (1ULL << 32)
436 438
437/* 439enum gmmu_pgsz_gk20a __get_pte_size_fixed_map(struct vm_gk20a *vm,
438 * The bottom 16GB of the space are used for small pages, the remaining high 440 u64 base, u64 size);
439 * memory is for large pages.
440 */
441static inline u64 __nv_gmmu_va_small_page_limit(void)
442{
443 return ((u64)SZ_1G * 16);
444}
445
446static inline int __nv_gmmu_va_is_big_page_region(struct vm_gk20a *vm, u64 addr)
447{
448 struct nvgpu_allocator *a = &vm->vma[gmmu_page_size_big];
449
450 if (!vm->big_pages)
451 return 0;
452
453 return addr >= nvgpu_alloc_base(a) &&
454 addr < nvgpu_alloc_base(a) + nvgpu_alloc_length(a);
455}
456 441
457/* 442/*
458 * This determines the PTE size for a given alloc. Used by both the GVA space 443 * This determines the PTE size for a given alloc. Used by both the GVA space
459 * allocator and the mm core code so that agreement can be reached on how to 444 * allocator and the mm core code so that agreement can be reached on how to
460 * map allocations. 445 * map allocations.
446 *
447 * The page size of a buffer is this:
448 *
449 * o If the VM doesn't support large pages then obviously small pages
450 * must be used.
451 * o If the base address is non-zero (fixed address map):
452 * - Attempt to find a reserved memory area and use the page size
453 * based on that.
454 * - If no reserved page size is available, default to small pages.
455 * o If the base is zero:
456 * - If the size is greater than or equal to the big page size, use big
457 * pages.
458 * - Otherwise use small pages.
461 */ 459 */
462static inline enum gmmu_pgsz_gk20a __get_pte_size(struct vm_gk20a *vm, 460static inline enum gmmu_pgsz_gk20a __get_pte_size(struct vm_gk20a *vm,
463 u64 base, u64 size) 461 u64 base, u64 size)
464{ 462{
465 /* 463 if (!vm->big_pages)
466 * Currently userspace is not ready for a true unified address space.
467 * As a result, even though the allocator supports mixed address spaces
468 * the address spaces must be treated as separate for now.
469 */
470 if (__nv_gmmu_va_is_big_page_region(vm, base))
471 return gmmu_page_size_big;
472 else
473 return gmmu_page_size_small; 464 return gmmu_page_size_small;
465
466 if (base)
467 return __get_pte_size_fixed_map(vm, base, size);
468
469 if (size >= vm->gmmu_page_sizes[gmmu_page_size_big])
470 return gmmu_page_size_big;
471 return gmmu_page_size_small;
474} 472}
475 473
476/* 474/*
@@ -797,6 +795,8 @@ void gk20a_mm_init_pdb(struct gk20a *g, struct mem_desc *mem,
797 795
798void gk20a_remove_vm(struct vm_gk20a *vm, struct mem_desc *inst_block); 796void gk20a_remove_vm(struct vm_gk20a *vm, struct mem_desc *inst_block);
799 797
798int gk20a_big_pages_possible(struct vm_gk20a *vm, u64 base, u64 size);
799
800extern const struct gk20a_mmu_level gk20a_mm_levels_64k[]; 800extern const struct gk20a_mmu_level gk20a_mm_levels_64k[];
801extern const struct gk20a_mmu_level gk20a_mm_levels_128k[]; 801extern const struct gk20a_mmu_level gk20a_mm_levels_128k[];
802 802