From 3fa47b877db1edc16018d662e7b9915d92354745 Mon Sep 17 00:00:00 2001 From: Debarshi Dutta Date: Tue, 8 Aug 2017 12:08:03 +0530 Subject: gpu: nvgpu: Replace kref for refcounting in nvgpu - added wrapper struct nvgpu_ref over nvgpu_atomic_t - added nvgpu_ref_* APIs to access the above struct JIRA NVGPU-140 Change-Id: Id47f897995dd4721751f7610b6d4d4fbfe4d6b9a Signed-off-by: Debarshi Dutta Reviewed-on: https://git-master.nvidia.com/r/1540899 Reviewed-by: svc-mobile-coverity Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit Reviewed-by: Konsta Holtta Reviewed-by: Vijayakumar Subbu --- drivers/gpu/nvgpu/gk20a/gk20a.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a/gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index 550b22c0..639ec4b5 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a.c @@ -511,7 +511,7 @@ int gk20a_init_gpu_characteristics(struct gk20a *g) /* * Free the gk20a struct. */ -static void gk20a_free_cb(struct kref *refcount) +static void gk20a_free_cb(struct nvgpu_ref *refcount) { struct gk20a *g = container_of(refcount, struct gk20a, refcount); @@ -544,10 +544,11 @@ struct gk20a * __must_check gk20a_get(struct gk20a *g) * the code will never be in such a situation that this race is * possible. */ - success = kref_get_unless_zero(&g->refcount); + success = nvgpu_ref_get_unless_zero(&g->refcount); gk20a_dbg(gpu_dbg_shutdown, "GET: refs currently %d %s", - atomic_read(&g->refcount.refcount), success ? "" : "(FAILED)"); + nvgpu_atomic_read(&g->refcount.refcount), + success ? "" : "(FAILED)"); return success ? g : NULL; } @@ -571,7 +572,7 @@ void gk20a_put(struct gk20a *g) * ... Freeing GK20A struct! */ gk20a_dbg(gpu_dbg_shutdown, "PUT: refs currently %d", - atomic_read(&g->refcount.refcount)); + nvgpu_atomic_read(&g->refcount.refcount)); - kref_put(&g->refcount, gk20a_free_cb); + nvgpu_ref_put(&g->refcount, gk20a_free_cb); } -- cgit v1.2.2