From 24e1c7e0a729158be36d63b821550d206a8a0436 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Wed, 8 Mar 2017 17:08:50 -0800 Subject: gpu: nvgpu: Use new kmem API functions (misc) Use the new kmem API functions in misc gk20a code. Some additional modifications were also made: o Add a struct gk20a pointer to gk20a_fence to enable proper kmem free usage. o Add gk20a pointer to alloc_session() in dbg_gpu_gk20a.c to use kmem API for allocating a session. o Plumb a gk20a pointer through the fence creation and deletion. o Use statically allocated buffers for names in file creation. Bug 1799159 Bug 1823380 Change-Id: I3678080e3ffa1f9bcf6934e3f4819a1bc531689b Signed-off-by: Alex Waterman Reviewed-on: http://git-master/r/1318323 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/fence_gk20a.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a/fence_gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/fence_gk20a.c b/drivers/gpu/nvgpu/gk20a/fence_gk20a.c index ea3cd3ff..63da0959 100644 --- a/drivers/gpu/nvgpu/gk20a/fence_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/fence_gk20a.c @@ -18,6 +18,7 @@ #include #include +#include #include "gk20a.h" #include "channel_gk20a.h" @@ -42,6 +43,8 @@ static void gk20a_fence_free(struct kref *ref) { struct gk20a_fence *f = container_of(ref, struct gk20a_fence, ref); + struct gk20a *g = f->g; + #ifdef CONFIG_SYNC if (f->sync_fence) sync_fence_put(f->sync_fence); @@ -53,7 +56,7 @@ static void gk20a_fence_free(struct kref *ref) if (nvgpu_alloc_initialized(f->allocator)) nvgpu_free(f->allocator, (size_t)f); } else - kfree(f); + nvgpu_kfree(g, f); } void gk20a_fence_put(struct gk20a_fence *f) @@ -124,7 +127,7 @@ int gk20a_alloc_fence_pool(struct channel_gk20a *c, unsigned int count) size = sizeof(struct gk20a_fence); if (count <= UINT_MAX / size) { size = count * size; - fence_pool = vzalloc(size); + fence_pool = nvgpu_vzalloc(c->g, size); } if (!fence_pool) @@ -139,7 +142,7 @@ int gk20a_alloc_fence_pool(struct channel_gk20a *c, unsigned int count) return 0; fail: - vfree(fence_pool); + nvgpu_vfree(c->g, fence_pool); return err; } @@ -150,7 +153,7 @@ void gk20a_free_fence_pool(struct channel_gk20a *c) nvgpu_alloc_base(&c->fence_allocator); nvgpu_alloc_destroy(&c->fence_allocator); - vfree(base); + nvgpu_vfree(c->g, base); } } @@ -171,10 +174,12 @@ struct gk20a_fence *gk20a_alloc_fence(struct channel_gk20a *c) } } } else - fence = kzalloc(sizeof(struct gk20a_fence), GFP_KERNEL); + fence = nvgpu_kzalloc(c->g, sizeof(struct gk20a_fence)); - if (fence) + if (fence) { kref_init(&fence->ref); + fence->g = c->g; + } return fence; } @@ -223,6 +228,7 @@ static const struct gk20a_fence_ops nvgpu_semaphore_fence_ops = { /* This function takes ownership of the semaphore */ int gk20a_fence_from_semaphore( + struct gk20a *g, struct gk20a_fence *fence_out, struct sync_timeline *timeline, struct nvgpu_semaphore *semaphore, @@ -235,7 +241,7 @@ int gk20a_fence_from_semaphore( #ifdef CONFIG_SYNC if (need_sync_fence) { - sync_fence = gk20a_sync_fence_create(timeline, semaphore, + sync_fence = gk20a_sync_fence_create(g, timeline, semaphore, dependency, "f-gk20a-0x%04x", nvgpu_semaphore_gpu_ro_va(semaphore)); if (!sync_fence) -- cgit v1.2.2