From b102c11a4fbf88423b0220fe019b7ad96fd31430 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Fri, 5 Aug 2016 17:17:24 -0700 Subject: gpu: nvgpu: Allow carveouts to be made in allocators Allow allocators to have regions of memory (carveouts) reserved from allocation. Bug 1799159 Jira DNVGPU-84 Change-Id: Id103e60ed1a6e63c433d1cf610c9f15227595750 Signed-off-by: Alex Waterman Reviewed-on: http://git-master/r/1200060 (cherry picked from commit 95f7c16b6fb49a570139a3a51828a9bca1c0abc8) Reviewed-on: http://git-master/r/1223452 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/gk20a_allocator.c | 16 +++++++++++++++ drivers/gpu/nvgpu/gk20a/gk20a_allocator.h | 34 +++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) (limited to 'drivers/gpu/nvgpu/gk20a') diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c b/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c index 3b20fa2e..f8e55788 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c @@ -88,6 +88,22 @@ void gk20a_free_fixed(struct gk20a_allocator *a, u64 base, u64 len) a->ops->free_fixed(a, base, len); } +int gk20a_alloc_reserve_carveout(struct gk20a_allocator *a, + struct gk20a_alloc_carveout *co) +{ + if (a->ops->reserve_carveout) + return a->ops->reserve_carveout(a, co); + + return -ENODEV; +} + +void gk20a_alloc_release_carveout(struct gk20a_allocator *a, + struct gk20a_alloc_carveout *co) +{ + if (a->ops->release_carveout) + a->ops->release_carveout(a, co); +} + void gk20a_alloc_destroy(struct gk20a_allocator *a) { a->ops->fini(a); diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_allocator.h b/drivers/gpu/nvgpu/gk20a/gk20a_allocator.h index 0d611ba3..40388ef8 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_allocator.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a_allocator.h @@ -24,6 +24,7 @@ /* #define ALLOCATOR_DEBUG */ struct gk20a_allocator; +struct gk20a_alloc_carveout; struct vm_gk20a; /* @@ -45,6 +46,14 @@ struct gk20a_allocator_ops { void (*free_fixed)(struct gk20a_allocator *allocator, u64 base, u64 len); + /* + * Allow allocators to reserve space for carveouts. + */ + int (*reserve_carveout)(struct gk20a_allocator *allocator, + struct gk20a_alloc_carveout *co); + void (*release_carveout)(struct gk20a_allocator *allocator, + struct gk20a_alloc_carveout *co); + /* * Returns info about the allocator. */ @@ -72,6 +81,26 @@ struct gk20a_allocator { bool debug; /* Control for debug msgs. */ }; +struct gk20a_alloc_carveout { + const char *name; + u64 base; + u64 length; + + struct gk20a_allocator *allocator; + + /* + * For usage by the allocator implementation. + */ + struct list_head co_entry; +}; + +#define GK20A_CARVEOUT(__name, __base, __length) \ + { \ + .name = (__name), \ + .base = (__base), \ + .length = (__length) \ + } + /* * These are the available allocator flags. * @@ -185,6 +214,11 @@ void gk20a_free(struct gk20a_allocator *allocator, u64 addr); u64 gk20a_alloc_fixed(struct gk20a_allocator *allocator, u64 base, u64 len); void gk20a_free_fixed(struct gk20a_allocator *allocator, u64 base, u64 len); +int gk20a_alloc_reserve_carveout(struct gk20a_allocator *a, + struct gk20a_alloc_carveout *co); +void gk20a_alloc_release_carveout(struct gk20a_allocator *a, + struct gk20a_alloc_carveout *co); + u64 gk20a_alloc_base(struct gk20a_allocator *a); u64 gk20a_alloc_length(struct gk20a_allocator *a); u64 gk20a_alloc_end(struct gk20a_allocator *a); -- cgit v1.2.2