diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a_allocator.c | 16 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a_allocator.h | 34 |
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 | ||
91 | int 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 | |||
100 | void 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 | |||
91 | void gk20a_alloc_destroy(struct gk20a_allocator *a) | 107 | void 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 | ||
26 | struct gk20a_allocator; | 26 | struct gk20a_allocator; |
27 | struct gk20a_alloc_carveout; | ||
27 | struct vm_gk20a; | 28 | struct 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 | ||
84 | struct 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); | |||
185 | u64 gk20a_alloc_fixed(struct gk20a_allocator *allocator, u64 base, u64 len); | 214 | u64 gk20a_alloc_fixed(struct gk20a_allocator *allocator, u64 base, u64 len); |
186 | void gk20a_free_fixed(struct gk20a_allocator *allocator, u64 base, u64 len); | 215 | void gk20a_free_fixed(struct gk20a_allocator *allocator, u64 base, u64 len); |
187 | 216 | ||
217 | int gk20a_alloc_reserve_carveout(struct gk20a_allocator *a, | ||
218 | struct gk20a_alloc_carveout *co); | ||
219 | void gk20a_alloc_release_carveout(struct gk20a_allocator *a, | ||
220 | struct gk20a_alloc_carveout *co); | ||
221 | |||
188 | u64 gk20a_alloc_base(struct gk20a_allocator *a); | 222 | u64 gk20a_alloc_base(struct gk20a_allocator *a); |
189 | u64 gk20a_alloc_length(struct gk20a_allocator *a); | 223 | u64 gk20a_alloc_length(struct gk20a_allocator *a); |
190 | u64 gk20a_alloc_end(struct gk20a_allocator *a); | 224 | u64 gk20a_alloc_end(struct gk20a_allocator *a); |