summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/include
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2018-07-02 20:14:27 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-09-09 20:20:43 -0400
commit3cf92ec89ba8deac77d726f02d79cba7c0e73e4d (patch)
tree9b20d30e81ab45d85eddbdf1cdd36901fd5a4ad2 /drivers/gpu/nvgpu/include
parent2dd9bb03dd56ca86b0e61b89fab38d38a58ecddf (diff)
gpu: nvgpu: Fix several issues with the buddy allocator
The issues are: 1. Non-fixed allocs must take into account explicit PTE size requests. Previously the PTE size was determines from the allocation size which was incorect. To do this, the PTE size is now plumbed through all GPU VA allocations. This is what the new alloc_pte() op does. 2. Fix buddy PTE size assignment. This changes a '<=' into a '<' in the buddy allocation logic. Effectively this is now leaving the PTE size for buddy blocks equal to the PDE block size as 'ANY'. This prevents a buddy block of PDE size which has yet to be allocated from having a specific PDE size. Without this its possible to do a fixed alloc that fails unexpectedly due to mismatching PDE sizes. Consider two PDE block sized fixed allocs that are contained in one buddy twice the size of a PDE block. Let's call these fixed allocs S and B (small and big). Let's assume that two fixed allocs are done, each targeting S and B, in that order. With the current logic the first alloc, when we create the two buddies S and B, causes both S and B to have a PTE size of SMALL. Now when the second alloc happens we attempt to find a buddy B with a PTE size of either BIG or ANY. But we cannot becasue B already has size SMALL. This casues us to appear like we have a conflicting fixed alloc despite this not being the case. 3. Misc cleanups & bug fixes: - Clean up some MISRA issues - Delete an extraneous unlock that could have caused a deadlock. Bug 200105199 Change-Id: Ib5447ec6705a5a289ac0cf3d5e90c79b5d67582d Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1768582 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/include')
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/allocator.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/allocator.h b/drivers/gpu/nvgpu/include/nvgpu/allocator.h
index 698aafb3..2d9b3d32 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/allocator.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/allocator.h
@@ -49,6 +49,8 @@ struct gk20a;
49 */ 49 */
50struct nvgpu_allocator_ops { 50struct nvgpu_allocator_ops {
51 u64 (*alloc)(struct nvgpu_allocator *allocator, u64 len); 51 u64 (*alloc)(struct nvgpu_allocator *allocator, u64 len);
52 u64 (*alloc_pte)(struct nvgpu_allocator *allocator, u64 len,
53 u32 page_size);
52 void (*free)(struct nvgpu_allocator *allocator, u64 addr); 54 void (*free)(struct nvgpu_allocator *allocator, u64 addr);
53 55
54 /* 56 /*
@@ -242,6 +244,7 @@ int nvgpu_lockless_allocator_init(struct gk20a *g, struct nvgpu_allocator *na,
242 * Allocator APIs. 244 * Allocator APIs.
243 */ 245 */
244u64 nvgpu_alloc(struct nvgpu_allocator *allocator, u64 len); 246u64 nvgpu_alloc(struct nvgpu_allocator *allocator, u64 len);
247u64 nvgpu_alloc_pte(struct nvgpu_allocator *a, u64 len, u32 page_size);
245void nvgpu_free(struct nvgpu_allocator *allocator, u64 addr); 248void nvgpu_free(struct nvgpu_allocator *allocator, u64 addr);
246 249
247u64 nvgpu_alloc_fixed(struct nvgpu_allocator *allocator, u64 base, u64 len, 250u64 nvgpu_alloc_fixed(struct nvgpu_allocator *allocator, u64 base, u64 len,