summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a
diff options
context:
space:
mode:
authorDebarshi Dutta <ddutta@nvidia.com>2017-08-08 02:38:03 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-08-24 04:10:37 -0400
commit3fa47b877db1edc16018d662e7b9915d92354745 (patch)
treec1d9a8734e7d92b5ae647fbc3f582a01207a23f6 /drivers/gpu/nvgpu/gk20a
parent8662fae334f2419da2e7fd220f7734217ec52433 (diff)
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 <ddutta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1540899 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a')
-rw-r--r--drivers/gpu/nvgpu/gk20a/fence_gk20a.c10
-rw-r--r--drivers/gpu/nvgpu/gk20a/fence_gk20a.h2
-rw-r--r--drivers/gpu/nvgpu/gk20a/fifo_gk20a.h2
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.c11
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.h2
-rw-r--r--drivers/gpu/nvgpu/gk20a/mm_gk20a.c15
-rw-r--r--drivers/gpu/nvgpu/gk20a/mm_gk20a.h2
-rw-r--r--drivers/gpu/nvgpu/gk20a/sched_gk20a.c20
-rw-r--r--drivers/gpu/nvgpu/gk20a/sync_gk20a.c10
-rw-r--r--drivers/gpu/nvgpu/gk20a/tsg_gk20a.c10
-rw-r--r--drivers/gpu/nvgpu/gk20a/tsg_gk20a.h4
11 files changed, 45 insertions, 43 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/fence_gk20a.c b/drivers/gpu/nvgpu/gk20a/fence_gk20a.c
index a7250b17..fdfef3da 100644
--- a/drivers/gpu/nvgpu/gk20a/fence_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/fence_gk20a.c
@@ -33,10 +33,10 @@
33struct gk20a_fence_ops { 33struct gk20a_fence_ops {
34 int (*wait)(struct gk20a_fence *, long timeout); 34 int (*wait)(struct gk20a_fence *, long timeout);
35 bool (*is_expired)(struct gk20a_fence *); 35 bool (*is_expired)(struct gk20a_fence *);
36 void *(*free)(struct kref *); 36 void *(*free)(struct nvgpu_ref *);
37}; 37};
38 38
39static void gk20a_fence_free(struct kref *ref) 39static void gk20a_fence_free(struct nvgpu_ref *ref)
40{ 40{
41 struct gk20a_fence *f = 41 struct gk20a_fence *f =
42 container_of(ref, struct gk20a_fence, ref); 42 container_of(ref, struct gk20a_fence, ref);
@@ -59,13 +59,13 @@ static void gk20a_fence_free(struct kref *ref)
59void gk20a_fence_put(struct gk20a_fence *f) 59void gk20a_fence_put(struct gk20a_fence *f)
60{ 60{
61 if (f) 61 if (f)
62 kref_put(&f->ref, gk20a_fence_free); 62 nvgpu_ref_put(&f->ref, gk20a_fence_free);
63} 63}
64 64
65struct gk20a_fence *gk20a_fence_get(struct gk20a_fence *f) 65struct gk20a_fence *gk20a_fence_get(struct gk20a_fence *f)
66{ 66{
67 if (f) 67 if (f)
68 kref_get(&f->ref); 68 nvgpu_ref_get(&f->ref);
69 return f; 69 return f;
70} 70}
71 71
@@ -175,7 +175,7 @@ struct gk20a_fence *gk20a_alloc_fence(struct channel_gk20a *c)
175 fence = nvgpu_kzalloc(c->g, sizeof(struct gk20a_fence)); 175 fence = nvgpu_kzalloc(c->g, sizeof(struct gk20a_fence));
176 176
177 if (fence) { 177 if (fence) {
178 kref_init(&fence->ref); 178 nvgpu_ref_init(&fence->ref);
179 fence->g = c->g; 179 fence->g = c->g;
180 } 180 }
181 181
diff --git a/drivers/gpu/nvgpu/gk20a/fence_gk20a.h b/drivers/gpu/nvgpu/gk20a/fence_gk20a.h
index 140f5488..e0eb09b6 100644
--- a/drivers/gpu/nvgpu/gk20a/fence_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/fence_gk20a.h
@@ -33,7 +33,7 @@ struct gk20a_fence {
33 33
34 /* Valid for all fence types: */ 34 /* Valid for all fence types: */
35 bool valid; 35 bool valid;
36 struct kref ref; 36 struct nvgpu_ref ref;
37 bool wfi; 37 bool wfi;
38 struct sync_fence *sync_fence; 38 struct sync_fence *sync_fence;
39 const struct gk20a_fence_ops *ops; 39 const struct gk20a_fence_ops *ops;
diff --git a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.h b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.h
index a6eae8ca..fb4932c8 100644
--- a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.h
@@ -159,7 +159,7 @@ struct fifo_gk20a {
159 nvgpu_atomic_t get; 159 nvgpu_atomic_t get;
160 bool enabled; 160 bool enabled;
161 u64 *sorted; 161 u64 *sorted;
162 struct kref ref; 162 struct nvgpu_ref ref;
163 struct nvgpu_mutex lock; 163 struct nvgpu_mutex lock;
164 } profile; 164 } profile;
165#endif 165#endif
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)
511/* 511/*
512 * Free the gk20a struct. 512 * Free the gk20a struct.
513 */ 513 */
514static void gk20a_free_cb(struct kref *refcount) 514static void gk20a_free_cb(struct nvgpu_ref *refcount)
515{ 515{
516 struct gk20a *g = container_of(refcount, 516 struct gk20a *g = container_of(refcount,
517 struct gk20a, refcount); 517 struct gk20a, refcount);
@@ -544,10 +544,11 @@ struct gk20a * __must_check gk20a_get(struct gk20a *g)
544 * the code will never be in such a situation that this race is 544 * the code will never be in such a situation that this race is
545 * possible. 545 * possible.
546 */ 546 */
547 success = kref_get_unless_zero(&g->refcount); 547 success = nvgpu_ref_get_unless_zero(&g->refcount);
548 548
549 gk20a_dbg(gpu_dbg_shutdown, "GET: refs currently %d %s", 549 gk20a_dbg(gpu_dbg_shutdown, "GET: refs currently %d %s",
550 atomic_read(&g->refcount.refcount), success ? "" : "(FAILED)"); 550 nvgpu_atomic_read(&g->refcount.refcount),
551 success ? "" : "(FAILED)");
551 552
552 return success ? g : NULL; 553 return success ? g : NULL;
553} 554}
@@ -571,7 +572,7 @@ void gk20a_put(struct gk20a *g)
571 * ... Freeing GK20A struct! 572 * ... Freeing GK20A struct!
572 */ 573 */
573 gk20a_dbg(gpu_dbg_shutdown, "PUT: refs currently %d", 574 gk20a_dbg(gpu_dbg_shutdown, "PUT: refs currently %d",
574 atomic_read(&g->refcount.refcount)); 575 nvgpu_atomic_read(&g->refcount.refcount));
575 576
576 kref_put(&g->refcount, gk20a_free_cb); 577 nvgpu_ref_put(&g->refcount, gk20a_free_cb);
577} 578}
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h
index 5efa846d..15e81291 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.h
@@ -1036,7 +1036,7 @@ struct gk20a {
1036 1036
1037 nvgpu_atomic_t usage_count; 1037 nvgpu_atomic_t usage_count;
1038 1038
1039 struct kref refcount; 1039 struct nvgpu_ref refcount;
1040 1040
1041 struct resource *reg_mem; 1041 struct resource *reg_mem;
1042 void __iomem *regs; 1042 void __iomem *regs;
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
index 2ce78cef..3030c170 100644
--- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
@@ -811,7 +811,7 @@ int nvgpu_vm_get_buffers(struct vm_gk20a *vm,
811 mapped_buffer = mapped_buffer_from_rbtree_node(node); 811 mapped_buffer = mapped_buffer_from_rbtree_node(node);
812 if (mapped_buffer->user_mapped) { 812 if (mapped_buffer->user_mapped) {
813 buffer_list[i] = mapped_buffer; 813 buffer_list[i] = mapped_buffer;
814 kref_get(&mapped_buffer->ref); 814 nvgpu_ref_get(&mapped_buffer->ref);
815 i++; 815 i++;
816 } 816 }
817 nvgpu_rbtree_enum_next(&node, node); 817 nvgpu_rbtree_enum_next(&node, node);
@@ -827,7 +827,7 @@ int nvgpu_vm_get_buffers(struct vm_gk20a *vm,
827 return 0; 827 return 0;
828} 828}
829 829
830void gk20a_vm_unmap_locked_kref(struct kref *ref) 830void gk20a_vm_unmap_locked_ref(struct nvgpu_ref *ref)
831{ 831{
832 struct nvgpu_mapped_buf *mapped_buffer = 832 struct nvgpu_mapped_buf *mapped_buffer =
833 container_of(ref, struct nvgpu_mapped_buf, ref); 833 container_of(ref, struct nvgpu_mapped_buf, ref);
@@ -849,8 +849,8 @@ void nvgpu_vm_put_buffers(struct vm_gk20a *vm,
849 vm->kref_put_batch = &batch; 849 vm->kref_put_batch = &batch;
850 850
851 for (i = 0; i < num_buffers; ++i) 851 for (i = 0; i < num_buffers; ++i)
852 kref_put(&mapped_buffers[i]->ref, 852 nvgpu_ref_put(&mapped_buffers[i]->ref,
853 gk20a_vm_unmap_locked_kref); 853 gk20a_vm_unmap_locked_ref);
854 854
855 vm->kref_put_batch = NULL; 855 vm->kref_put_batch = NULL;
856 nvgpu_vm_mapping_batch_finish_locked(vm, &batch); 856 nvgpu_vm_mapping_batch_finish_locked(vm, &batch);
@@ -882,8 +882,9 @@ static void nvgpu_vm_unmap_user(struct vm_gk20a *vm, u64 offset,
882 nvgpu_timeout_init(vm->mm->g, &timeout, 10000, 882 nvgpu_timeout_init(vm->mm->g, &timeout, 10000,
883 NVGPU_TIMER_RETRY_TIMER); 883 NVGPU_TIMER_RETRY_TIMER);
884 do { 884 do {
885 if (atomic_read(&mapped_buffer->ref.refcount) == 1) 885 if (nvgpu_atomic_read(
886 break; 886 &mapped_buffer->ref.refcount) == 1)
887 break;
887 nvgpu_udelay(5); 888 nvgpu_udelay(5);
888 } while (!nvgpu_timeout_expired_msg(&timeout, 889 } while (!nvgpu_timeout_expired_msg(&timeout,
889 "sync-unmap failed on 0x%llx")); 890 "sync-unmap failed on 0x%llx"));
@@ -902,7 +903,7 @@ static void nvgpu_vm_unmap_user(struct vm_gk20a *vm, u64 offset,
902 vm->num_user_mapped_buffers--; 903 vm->num_user_mapped_buffers--;
903 904
904 vm->kref_put_batch = batch; 905 vm->kref_put_batch = batch;
905 kref_put(&mapped_buffer->ref, gk20a_vm_unmap_locked_kref); 906 nvgpu_ref_put(&mapped_buffer->ref, gk20a_vm_unmap_locked_ref);
906 vm->kref_put_batch = NULL; 907 vm->kref_put_batch = NULL;
907 908
908 nvgpu_mutex_release(&vm->update_gmmu_lock); 909 nvgpu_mutex_release(&vm->update_gmmu_lock);
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h
index e8b90c8f..82a4ee85 100644
--- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h
@@ -434,6 +434,6 @@ extern const struct gk20a_mmu_level gk20a_mm_levels_128k[];
434 434
435int gk20a_mm_get_buffer_info(struct device *dev, int dmabuf_fd, 435int gk20a_mm_get_buffer_info(struct device *dev, int dmabuf_fd,
436 u64 *buffer_id, u64 *buffer_len); 436 u64 *buffer_id, u64 *buffer_len);
437void gk20a_vm_unmap_locked_kref(struct kref *ref); 437void gk20a_vm_unmap_locked_ref(struct nvgpu_ref *ref);
438 438
439#endif /* MM_GK20A_H */ 439#endif /* MM_GK20A_H */
diff --git a/drivers/gpu/nvgpu/gk20a/sched_gk20a.c b/drivers/gpu/nvgpu/gk20a/sched_gk20a.c
index 014848ba..ac54addd 100644
--- a/drivers/gpu/nvgpu/gk20a/sched_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/sched_gk20a.c
@@ -189,7 +189,7 @@ static int gk20a_sched_dev_ioctl_get_params(struct gk20a_sched_ctrl *sched,
189 return -EINVAL; 189 return -EINVAL;
190 190
191 tsg = &f->tsg[tsgid]; 191 tsg = &f->tsg[tsgid];
192 if (!kref_get_unless_zero(&tsg->refcount)) 192 if (!nvgpu_ref_get_unless_zero(&tsg->refcount))
193 return -ENXIO; 193 return -ENXIO;
194 194
195 arg->pid = tsg->tgid; /* kernel tgid corresponds to user pid */ 195 arg->pid = tsg->tgid; /* kernel tgid corresponds to user pid */
@@ -206,7 +206,7 @@ static int gk20a_sched_dev_ioctl_get_params(struct gk20a_sched_ctrl *sched,
206 arg->compute_preempt_mode = 0; 206 arg->compute_preempt_mode = 0;
207 } 207 }
208 208
209 kref_put(&tsg->refcount, gk20a_tsg_release); 209 nvgpu_ref_put(&tsg->refcount, gk20a_tsg_release);
210 210
211 return 0; 211 return 0;
212} 212}
@@ -227,7 +227,7 @@ static int gk20a_sched_dev_ioctl_tsg_set_timeslice(
227 return -EINVAL; 227 return -EINVAL;
228 228
229 tsg = &f->tsg[tsgid]; 229 tsg = &f->tsg[tsgid];
230 if (!kref_get_unless_zero(&tsg->refcount)) 230 if (!nvgpu_ref_get_unless_zero(&tsg->refcount))
231 return -ENXIO; 231 return -ENXIO;
232 232
233 err = gk20a_busy(g); 233 err = gk20a_busy(g);
@@ -239,7 +239,7 @@ static int gk20a_sched_dev_ioctl_tsg_set_timeslice(
239 gk20a_idle(g); 239 gk20a_idle(g);
240 240
241done: 241done:
242 kref_put(&tsg->refcount, gk20a_tsg_release); 242 nvgpu_ref_put(&tsg->refcount, gk20a_tsg_release);
243 243
244 return err; 244 return err;
245} 245}
@@ -260,7 +260,7 @@ static int gk20a_sched_dev_ioctl_tsg_set_runlist_interleave(
260 return -EINVAL; 260 return -EINVAL;
261 261
262 tsg = &f->tsg[tsgid]; 262 tsg = &f->tsg[tsgid];
263 if (!kref_get_unless_zero(&tsg->refcount)) 263 if (!nvgpu_ref_get_unless_zero(&tsg->refcount))
264 return -ENXIO; 264 return -ENXIO;
265 265
266 err = gk20a_busy(g); 266 err = gk20a_busy(g);
@@ -272,7 +272,7 @@ static int gk20a_sched_dev_ioctl_tsg_set_runlist_interleave(
272 gk20a_idle(g); 272 gk20a_idle(g);
273 273
274done: 274done:
275 kref_put(&tsg->refcount, gk20a_tsg_release); 275 nvgpu_ref_put(&tsg->refcount, gk20a_tsg_release);
276 276
277 return err; 277 return err;
278} 278}
@@ -320,7 +320,7 @@ static int gk20a_sched_dev_ioctl_get_tsg(struct gk20a_sched_ctrl *sched,
320 return -EINVAL; 320 return -EINVAL;
321 321
322 tsg = &f->tsg[tsgid]; 322 tsg = &f->tsg[tsgid];
323 if (!kref_get_unless_zero(&tsg->refcount)) 323 if (!nvgpu_ref_get_unless_zero(&tsg->refcount))
324 return -ENXIO; 324 return -ENXIO;
325 325
326 nvgpu_mutex_acquire(&sched->status_lock); 326 nvgpu_mutex_acquire(&sched->status_lock);
@@ -328,7 +328,7 @@ static int gk20a_sched_dev_ioctl_get_tsg(struct gk20a_sched_ctrl *sched,
328 nvgpu_warn(g, "tsgid=%d already referenced", tsgid); 328 nvgpu_warn(g, "tsgid=%d already referenced", tsgid);
329 /* unlock status_lock as gk20a_tsg_release locks it */ 329 /* unlock status_lock as gk20a_tsg_release locks it */
330 nvgpu_mutex_release(&sched->status_lock); 330 nvgpu_mutex_release(&sched->status_lock);
331 kref_put(&tsg->refcount, gk20a_tsg_release); 331 nvgpu_ref_put(&tsg->refcount, gk20a_tsg_release);
332 return -ENXIO; 332 return -ENXIO;
333 } 333 }
334 334
@@ -364,7 +364,7 @@ static int gk20a_sched_dev_ioctl_put_tsg(struct gk20a_sched_ctrl *sched,
364 nvgpu_mutex_release(&sched->status_lock); 364 nvgpu_mutex_release(&sched->status_lock);
365 365
366 tsg = &f->tsg[tsgid]; 366 tsg = &f->tsg[tsgid];
367 kref_put(&tsg->refcount, gk20a_tsg_release); 367 nvgpu_ref_put(&tsg->refcount, gk20a_tsg_release);
368 368
369 return 0; 369 return 0;
370} 370}
@@ -507,7 +507,7 @@ int gk20a_sched_dev_release(struct inode *inode, struct file *filp)
507 for (tsgid = 0; tsgid < f->num_channels; tsgid++) { 507 for (tsgid = 0; tsgid < f->num_channels; tsgid++) {
508 if (NVGPU_SCHED_ISSET(tsgid, sched->ref_tsg_bitmap)) { 508 if (NVGPU_SCHED_ISSET(tsgid, sched->ref_tsg_bitmap)) {
509 tsg = &f->tsg[tsgid]; 509 tsg = &f->tsg[tsgid];
510 kref_put(&tsg->refcount, gk20a_tsg_release); 510 nvgpu_ref_put(&tsg->refcount, gk20a_tsg_release);
511 } 511 }
512 } 512 }
513 513
diff --git a/drivers/gpu/nvgpu/gk20a/sync_gk20a.c b/drivers/gpu/nvgpu/gk20a/sync_gk20a.c
index deaf19a1..a8e824b6 100644
--- a/drivers/gpu/nvgpu/gk20a/sync_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/sync_gk20a.c
@@ -43,7 +43,7 @@ struct gk20a_sync_timeline {
43 */ 43 */
44struct gk20a_sync_pt { 44struct gk20a_sync_pt {
45 struct gk20a *g; 45 struct gk20a *g;
46 struct kref refcount; 46 struct nvgpu_ref refcount;
47 u32 thresh; 47 u32 thresh;
48 struct nvgpu_semaphore *sema; 48 struct nvgpu_semaphore *sema;
49 struct gk20a_sync_timeline *obj; 49 struct gk20a_sync_timeline *obj;
@@ -170,7 +170,7 @@ static struct gk20a_sync_timeline *to_gk20a_timeline(struct sync_timeline *obj)
170 return (struct gk20a_sync_timeline *)obj; 170 return (struct gk20a_sync_timeline *)obj;
171} 171}
172 172
173static void gk20a_sync_pt_free_shared(struct kref *ref) 173static void gk20a_sync_pt_free_shared(struct nvgpu_ref *ref)
174{ 174{
175 struct gk20a_sync_pt *pt = 175 struct gk20a_sync_pt *pt =
176 container_of(ref, struct gk20a_sync_pt, refcount); 176 container_of(ref, struct gk20a_sync_pt, refcount);
@@ -192,7 +192,7 @@ static struct gk20a_sync_pt *gk20a_sync_pt_create_shared(
192 if (!shared) 192 if (!shared)
193 return NULL; 193 return NULL;
194 194
195 kref_init(&shared->refcount); 195 nvgpu_ref_init(&shared->refcount);
196 shared->g = g; 196 shared->g = g;
197 shared->obj = obj; 197 shared->obj = obj;
198 shared->sema = sema; 198 shared->sema = sema;
@@ -229,7 +229,7 @@ static void gk20a_sync_pt_free_inst(struct sync_pt *sync_pt)
229{ 229{
230 struct gk20a_sync_pt *pt = to_gk20a_sync_pt(sync_pt); 230 struct gk20a_sync_pt *pt = to_gk20a_sync_pt(sync_pt);
231 if (pt) 231 if (pt)
232 kref_put(&pt->refcount, gk20a_sync_pt_free_shared); 232 nvgpu_ref_put(&pt->refcount, gk20a_sync_pt_free_shared);
233} 233}
234 234
235static struct sync_pt *gk20a_sync_pt_dup_inst(struct sync_pt *sync_pt) 235static struct sync_pt *gk20a_sync_pt_dup_inst(struct sync_pt *sync_pt)
@@ -242,7 +242,7 @@ static struct sync_pt *gk20a_sync_pt_dup_inst(struct sync_pt *sync_pt)
242 if (!pti) 242 if (!pti)
243 return NULL; 243 return NULL;
244 pti->shared = pt; 244 pti->shared = pt;
245 kref_get(&pt->refcount); 245 nvgpu_ref_get(&pt->refcount);
246 return &pti->pt; 246 return &pti->pt;
247} 247}
248 248
diff --git a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c
index 99d72292..f3e87a13 100644
--- a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c
@@ -104,7 +104,7 @@ int gk20a_tsg_bind_channel(struct tsg_gk20a *tsg,
104 nvgpu_list_add_tail(&ch->ch_entry, &tsg->ch_list); 104 nvgpu_list_add_tail(&ch->ch_entry, &tsg->ch_list);
105 up_write(&tsg->ch_list_lock); 105 up_write(&tsg->ch_list_lock);
106 106
107 kref_get(&tsg->refcount); 107 nvgpu_ref_get(&tsg->refcount);
108 108
109 gk20a_dbg(gpu_dbg_fn, "BIND tsg:%d channel:%d\n", 109 gk20a_dbg(gpu_dbg_fn, "BIND tsg:%d channel:%d\n",
110 tsg->tsgid, ch->chid); 110 tsg->tsgid, ch->chid);
@@ -122,7 +122,7 @@ int gk20a_tsg_unbind_channel(struct channel_gk20a *ch)
122 nvgpu_list_del(&ch->ch_entry); 122 nvgpu_list_del(&ch->ch_entry);
123 up_write(&tsg->ch_list_lock); 123 up_write(&tsg->ch_list_lock);
124 124
125 kref_put(&tsg->refcount, gk20a_tsg_release); 125 nvgpu_ref_put(&tsg->refcount, gk20a_tsg_release);
126 126
127 ch->tsgid = NVGPU_INVALID_TSG_ID; 127 ch->tsgid = NVGPU_INVALID_TSG_ID;
128 128
@@ -257,7 +257,7 @@ struct tsg_gk20a *gk20a_tsg_open(struct gk20a *g)
257 257
258 tsg->g = g; 258 tsg->g = g;
259 tsg->num_active_channels = 0; 259 tsg->num_active_channels = 0;
260 kref_init(&tsg->refcount); 260 nvgpu_ref_init(&tsg->refcount);
261 261
262 tsg->tsg_gr_ctx = NULL; 262 tsg->tsg_gr_ctx = NULL;
263 tsg->vm = NULL; 263 tsg->vm = NULL;
@@ -287,11 +287,11 @@ struct tsg_gk20a *gk20a_tsg_open(struct gk20a *g)
287 return tsg; 287 return tsg;
288 288
289clean_up: 289clean_up:
290 kref_put(&tsg->refcount, gk20a_tsg_release); 290 nvgpu_ref_put(&tsg->refcount, gk20a_tsg_release);
291 return NULL; 291 return NULL;
292} 292}
293 293
294void gk20a_tsg_release(struct kref *ref) 294void gk20a_tsg_release(struct nvgpu_ref *ref)
295{ 295{
296 struct tsg_gk20a *tsg = container_of(ref, struct tsg_gk20a, refcount); 296 struct tsg_gk20a *tsg = container_of(ref, struct tsg_gk20a, refcount);
297 struct gk20a *g = tsg->g; 297 struct gk20a *g = tsg->g;
diff --git a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h
index 40e12105..9195d3d3 100644
--- a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h
@@ -25,7 +25,7 @@ struct channel_gk20a;
25 25
26bool gk20a_is_channel_marked_as_tsg(struct channel_gk20a *ch); 26bool gk20a_is_channel_marked_as_tsg(struct channel_gk20a *ch);
27struct tsg_gk20a *gk20a_tsg_open(struct gk20a *g); 27struct tsg_gk20a *gk20a_tsg_open(struct gk20a *g);
28void gk20a_tsg_release(struct kref *ref); 28void gk20a_tsg_release(struct nvgpu_ref *ref);
29 29
30int gk20a_init_tsg_support(struct gk20a *g, u32 tsgid); 30int gk20a_init_tsg_support(struct gk20a *g, u32 tsgid);
31struct tsg_gk20a *tsg_gk20a_from_ch(struct channel_gk20a *ch); 31struct tsg_gk20a *tsg_gk20a_from_ch(struct channel_gk20a *ch);
@@ -36,7 +36,7 @@ struct tsg_gk20a {
36 bool in_use; 36 bool in_use;
37 int tsgid; 37 int tsgid;
38 38
39 struct kref refcount; 39 struct nvgpu_ref refcount;
40 40
41 struct nvgpu_list_node ch_list; 41 struct nvgpu_list_node ch_list;
42 int num_active_channels; 42 int num_active_channels;