summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
diff options
context:
space:
mode:
authorKonsta Holtta <kholtta@nvidia.com>2015-12-01 04:55:27 -0500
committerTerje Bergstrom <tbergstrom@nvidia.com>2016-01-19 20:44:27 -0500
commitdb7095ce5180552d1a70fdea779e5987d55cce7b (patch)
tree35b9125f86efbfca657910f33a49b1c08ddc6acc /drivers/gpu/nvgpu/gk20a/gr_gk20a.c
parent7095a72e563b5d7969c5f09053e469906362428f (diff)
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 <kholtta@nvidia.com> Reviewed-on: http://git-master/r/837180 (cherry picked from commit 5a504aeb54f3e89e6561932971158a397157b3f2) Reviewed-on: http://git-master/r/839742 Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Tested-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/gr_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/gr_gk20a.c29
1 files changed, 28 insertions, 1 deletions
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,
2878 return 0; 2878 return 0;
2879} 2879}
2880 2880
2881int gk20a_comptag_allocator_init(struct gk20a_comptag_allocator *allocator,
2882 unsigned long size)
2883{
2884 mutex_init(&allocator->lock);
2885 /*
2886 * 0th comptag is special and is never used. The base for this bitmap
2887 * is 1, and its size is one less than the size of comptag store.
2888 */
2889 size--;
2890 allocator->bitmap = vzalloc(BITS_TO_LONGS(size) * sizeof(long));
2891 if (!allocator->bitmap)
2892 return -ENOMEM;
2893 allocator->size = size;
2894 return 0;
2895}
2896
2897void gk20a_comptag_allocator_destroy(struct gk20a_comptag_allocator *allocator)
2898{
2899 /*
2900 * called only when exiting the driver (gk20a_remove, or unwinding the
2901 * init stage); no users should be active, so taking the mutex is
2902 * unnecessary here.
2903 */
2904 allocator->size = 0;
2905 vfree(allocator->bitmap);
2906}
2907
2881static void gk20a_remove_gr_support(struct gr_gk20a *gr) 2908static void gk20a_remove_gr_support(struct gr_gk20a *gr)
2882{ 2909{
2883 struct gk20a *g = gr->g; 2910 struct gk20a *g = gr->g;
@@ -2936,7 +2963,7 @@ static void gk20a_remove_gr_support(struct gr_gk20a *gr)
2936 kfree(gr->ctx_vars.local_golden_image); 2963 kfree(gr->ctx_vars.local_golden_image);
2937 gr->ctx_vars.local_golden_image = NULL; 2964 gr->ctx_vars.local_golden_image = NULL;
2938 2965
2939 gk20a_allocator_destroy(&gr->comp_tags); 2966 gk20a_comptag_allocator_destroy(&gr->comp_tags);
2940} 2967}
2941 2968
2942static void gr_gk20a_bundle_cb_defaults(struct gk20a *g) 2969static void gr_gk20a_bundle_cb_defaults(struct gk20a *g)