summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2016-08-05 20:17:24 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2016-09-20 17:56:38 -0400
commitb102c11a4fbf88423b0220fe019b7ad96fd31430 (patch)
treef5a82720f7bd890d843bcc65cb9de7f58373cdc3 /drivers
parent35b2507fe3ec6c28c27dd7fb289c003c7a0baf33 (diff)
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 <alexw@nvidia.com> Reviewed-on: http://git-master/r/1200060 (cherry picked from commit 95f7c16b6fb49a570139a3a51828a9bca1c0abc8) Reviewed-on: http://git-master/r/1223452 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a_allocator.c16
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a_allocator.h34
2 files changed, 50 insertions, 0 deletions
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)
88 a->ops->free_fixed(a, base, len); 88 a->ops->free_fixed(a, base, len);
89} 89}
90 90
91int gk20a_alloc_reserve_carveout(struct gk20a_allocator *a,
92 struct gk20a_alloc_carveout *co)
93{
94 if (a->ops->reserve_carveout)
95 return a->ops->reserve_carveout(a, co);
96
97 return -ENODEV;
98}
99
100void gk20a_alloc_release_carveout(struct gk20a_allocator *a,
101 struct gk20a_alloc_carveout *co)
102{
103 if (a->ops->release_carveout)
104 a->ops->release_carveout(a, co);
105}
106
91void gk20a_alloc_destroy(struct gk20a_allocator *a) 107void gk20a_alloc_destroy(struct gk20a_allocator *a)
92{ 108{
93 a->ops->fini(a); 109 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 @@
24/* #define ALLOCATOR_DEBUG */ 24/* #define ALLOCATOR_DEBUG */
25 25
26struct gk20a_allocator; 26struct gk20a_allocator;
27struct gk20a_alloc_carveout;
27struct vm_gk20a; 28struct vm_gk20a;
28 29
29/* 30/*
@@ -46,6 +47,14 @@ struct gk20a_allocator_ops {
46 u64 base, u64 len); 47 u64 base, u64 len);
47 48
48 /* 49 /*
50 * Allow allocators to reserve space for carveouts.
51 */
52 int (*reserve_carveout)(struct gk20a_allocator *allocator,
53 struct gk20a_alloc_carveout *co);
54 void (*release_carveout)(struct gk20a_allocator *allocator,
55 struct gk20a_alloc_carveout *co);
56
57 /*
49 * Returns info about the allocator. 58 * Returns info about the allocator.
50 */ 59 */
51 u64 (*base)(struct gk20a_allocator *allocator); 60 u64 (*base)(struct gk20a_allocator *allocator);
@@ -72,6 +81,26 @@ struct gk20a_allocator {
72 bool debug; /* Control for debug msgs. */ 81 bool debug; /* Control for debug msgs. */
73}; 82};
74 83
84struct gk20a_alloc_carveout {
85 const char *name;
86 u64 base;
87 u64 length;
88
89 struct gk20a_allocator *allocator;
90
91 /*
92 * For usage by the allocator implementation.
93 */
94 struct list_head co_entry;
95};
96
97#define GK20A_CARVEOUT(__name, __base, __length) \
98 { \
99 .name = (__name), \
100 .base = (__base), \
101 .length = (__length) \
102 }
103
75/* 104/*
76 * These are the available allocator flags. 105 * These are the available allocator flags.
77 * 106 *
@@ -185,6 +214,11 @@ void gk20a_free(struct gk20a_allocator *allocator, u64 addr);
185u64 gk20a_alloc_fixed(struct gk20a_allocator *allocator, u64 base, u64 len); 214u64 gk20a_alloc_fixed(struct gk20a_allocator *allocator, u64 base, u64 len);
186void gk20a_free_fixed(struct gk20a_allocator *allocator, u64 base, u64 len); 215void gk20a_free_fixed(struct gk20a_allocator *allocator, u64 base, u64 len);
187 216
217int gk20a_alloc_reserve_carveout(struct gk20a_allocator *a,
218 struct gk20a_alloc_carveout *co);
219void gk20a_alloc_release_carveout(struct gk20a_allocator *a,
220 struct gk20a_alloc_carveout *co);
221
188u64 gk20a_alloc_base(struct gk20a_allocator *a); 222u64 gk20a_alloc_base(struct gk20a_allocator *a);
189u64 gk20a_alloc_length(struct gk20a_allocator *a); 223u64 gk20a_alloc_length(struct gk20a_allocator *a);
190u64 gk20a_alloc_end(struct gk20a_allocator *a); 224u64 gk20a_alloc_end(struct gk20a_allocator *a);