From db7095ce5180552d1a70fdea779e5987d55cce7b Mon Sep 17 00:00:00 2001 From: Konsta Holtta Date: Tue, 1 Dec 2015 11:55:27 +0200 Subject: gpu: nvgpu: bitmap allocator for comptags Restore comptags to be bitmap-allocated, like they were before we had the buddy allocator. The new buddy allocator introduced by e99aa2485f8992eabe3556f3ebcb57bdc8ad91ff (originally 6ab2e0c49cb79ca68d2f83f1d4610783d2eaa79b) is fine for the big VAs, but unsuitable for the small compbit store. This commit reverts partially the combination of the above commit and also one after it, 86fc7ec9a05999bea8de320840b962db3ee11410, that fixed a bug which is not present when using a bitmap. With a bitmap allocator, pruning the extra allocation necessary for user-mapped mode is possible, so that is also restored. The original generic bitmap allocator is not restored; instead, a comptag-only allocator is introduced. Bug 200145635 Change-Id: I87f3a911826a801124cfd21e44857dfab1c3f378 Signed-off-by: Konsta Holtta Reviewed-on: http://git-master/r/837180 (cherry picked from commit 5a504aeb54f3e89e6561932971158a397157b3f2) Reviewed-on: http://git-master/r/839742 Reviewed-by: Terje Bergstrom Tested-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/gr_gk20a.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'drivers/gpu/nvgpu/gk20a/gr_gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c index 55262a8f..f31f7170 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c @@ -2878,6 +2878,33 @@ int gk20a_free_obj_ctx(struct channel_gk20a *c, return 0; } +int gk20a_comptag_allocator_init(struct gk20a_comptag_allocator *allocator, + unsigned long size) +{ + mutex_init(&allocator->lock); + /* + * 0th comptag is special and is never used. The base for this bitmap + * is 1, and its size is one less than the size of comptag store. + */ + size--; + allocator->bitmap = vzalloc(BITS_TO_LONGS(size) * sizeof(long)); + if (!allocator->bitmap) + return -ENOMEM; + allocator->size = size; + return 0; +} + +void gk20a_comptag_allocator_destroy(struct gk20a_comptag_allocator *allocator) +{ + /* + * called only when exiting the driver (gk20a_remove, or unwinding the + * init stage); no users should be active, so taking the mutex is + * unnecessary here. + */ + allocator->size = 0; + vfree(allocator->bitmap); +} + static void gk20a_remove_gr_support(struct gr_gk20a *gr) { struct gk20a *g = gr->g; @@ -2936,7 +2963,7 @@ static void gk20a_remove_gr_support(struct gr_gk20a *gr) kfree(gr->ctx_vars.local_golden_image); gr->ctx_vars.local_golden_image = NULL; - gk20a_allocator_destroy(&gr->comp_tags); + gk20a_comptag_allocator_destroy(&gr->comp_tags); } static void gr_gk20a_bundle_cb_defaults(struct gk20a *g) -- cgit v1.2.2