summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2016-06-22 18:55:21 -0400
committerTerje Bergstrom <tbergstrom@nvidia.com>2016-06-23 16:02:44 -0400
commit41ec68376ff4291f9aa50df014439ce462a8e87f (patch)
tree44647a49e554cd14591d5ea6f780b51e4fe8c1c3 /drivers
parentdf1ff34809756aba22957e19cb39c205f271f856 (diff)
gpu: nvgpu: Handle allocators with a base of 0
When an allocator is created with a base of 0 the first allocated block could well be 0. This appears to be an error since gk20a_balloc() normally returns 0 for error cases. This patch removes one block from the allocatable resources when base is set to 0 so that code using gk20a_balloc() does not get tricked into thinking valid allocations are OOM cases. Change-Id: I641642d3f790c4c7860d0d1381f4db6f4f72e709 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: http://git-master/r/1169764 Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Tested-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a_allocator.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c b/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c
index fd721709..d3a9202b 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c
+++ b/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c
@@ -285,6 +285,15 @@ int __gk20a_allocator_init(struct gk20a_allocator *a,
285 a->blk_size = blk_size; 285 a->blk_size = blk_size;
286 a->blk_shift = __ffs(blk_size); 286 a->blk_shift = __ffs(blk_size);
287 287
288 /*
289 * If base is 0 then modfy base to be the size of one block so that we
290 * can return errors by returning addr == 0.
291 */
292 if (a->base == 0) {
293 a->base = a->blk_size;
294 a->length -= a->blk_size;
295 }
296
288 /* blk_size must be greater than 0 and a power of 2. */ 297 /* blk_size must be greater than 0 and a power of 2. */
289 if (blk_size == 0) 298 if (blk_size == 0)
290 return -EINVAL; 299 return -EINVAL;