summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/include
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/include
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/include')
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/allocator.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/allocator.h b/drivers/gpu/nvgpu/include/nvgpu/allocator.h
index dee9b562..d5a90c87 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/allocator.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/allocator.h
@@ -41,11 +41,15 @@ struct nvgpu_allocator_ops {
41 * regular and fixed allocations then free_fixed() does not need to 41 * regular and fixed allocations then free_fixed() does not need to
42 * be implemented. This behavior exists for legacy reasons and should 42 * be implemented. This behavior exists for legacy reasons and should
43 * not be propagated to new allocators. 43 * not be propagated to new allocators.
44 *
45 * For allocators where the @page_size field is not applicable it can
46 * be left as 0. Otherwise a valid page size should be passed (4k or
47 * what the large page size is).
44 */ 48 */
45 u64 (*alloc_fixed)(struct nvgpu_allocator *allocator, 49 u64 (*alloc_fixed)(struct nvgpu_allocator *allocator,
46 u64 base, u64 len); 50 u64 base, u64 len, u32 page_size);
47 void (*free_fixed)(struct nvgpu_allocator *allocator, 51 void (*free_fixed)(struct nvgpu_allocator *allocator,
48 u64 base, u64 len); 52 u64 base, u64 len);
49 53
50 /* 54 /*
51 * Allow allocators to reserve space for carveouts. 55 * Allow allocators to reserve space for carveouts.
@@ -213,7 +217,8 @@ int nvgpu_lockless_allocator_init(struct gk20a *g, struct nvgpu_allocator *a,
213u64 nvgpu_alloc(struct nvgpu_allocator *allocator, u64 len); 217u64 nvgpu_alloc(struct nvgpu_allocator *allocator, u64 len);
214void nvgpu_free(struct nvgpu_allocator *allocator, u64 addr); 218void nvgpu_free(struct nvgpu_allocator *allocator, u64 addr);
215 219
216u64 nvgpu_alloc_fixed(struct nvgpu_allocator *allocator, u64 base, u64 len); 220u64 nvgpu_alloc_fixed(struct nvgpu_allocator *allocator, u64 base, u64 len,
221 u32 page_size);
217void nvgpu_free_fixed(struct nvgpu_allocator *allocator, u64 base, u64 len); 222void nvgpu_free_fixed(struct nvgpu_allocator *allocator, u64 base, u64 len);
218 223
219int nvgpu_alloc_reserve_carveout(struct nvgpu_allocator *a, 224int nvgpu_alloc_reserve_carveout(struct nvgpu_allocator *a,
@@ -298,5 +303,8 @@ void nvgpu_alloc_debugfs_init(struct device *dev);
298 } while (0) 303 } while (0)
299 304
300#endif 305#endif
306#define balloc_pr(alloctor, format, arg...) \
307 pr_info("%-25s %25s() " format, \
308 alloctor->name, __func__, ##arg)
301 309
302#endif /* NVGPU_ALLOCATOR_H */ 310#endif /* NVGPU_ALLOCATOR_H */