summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/linux/debug_fifo.c
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/common/linux/debug_fifo.c
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/common/linux/debug_fifo.c')
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug_fifo.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/debug_fifo.c b/drivers/gpu/nvgpu/common/linux/debug_fifo.c
index 1763eb7e..59198718 100644
--- a/drivers/gpu/nvgpu/common/linux/debug_fifo.c
+++ b/drivers/gpu/nvgpu/common/linux/debug_fifo.c
@@ -20,7 +20,7 @@
20 20
21#include <nvgpu/sort.h> 21#include <nvgpu/sort.h>
22 22
23void __gk20a_fifo_profile_free(struct kref *ref); 23void __gk20a_fifo_profile_free(struct nvgpu_ref *ref);
24 24
25static void *gk20a_fifo_sched_debugfs_seq_start( 25static void *gk20a_fifo_sched_debugfs_seq_start(
26 struct seq_file *s, loff_t *pos) 26 struct seq_file *s, loff_t *pos)
@@ -145,14 +145,15 @@ static int gk20a_fifo_profile_enable(void *data, u64 val)
145 if (val == 0) { 145 if (val == 0) {
146 if (f->profile.enabled) { 146 if (f->profile.enabled) {
147 f->profile.enabled = false; 147 f->profile.enabled = false;
148 kref_put(&f->profile.ref, __gk20a_fifo_profile_free); 148 nvgpu_ref_put(&f->profile.ref,
149 __gk20a_fifo_profile_free);
149 } 150 }
150 } else { 151 } else {
151 if (!f->profile.enabled) { 152 if (!f->profile.enabled) {
152 /* not kref init as it can have a running condition if 153 /* not kref init as it can have a running condition if
153 * we enable/disable/enable while kickoff is happening 154 * we enable/disable/enable while kickoff is happening
154 */ 155 */
155 if (!kref_get_unless_zero(&f->profile.ref)) { 156 if (!nvgpu_ref_get_unless_zero(&f->profile.ref)) {
156 f->profile.data = vzalloc( 157 f->profile.data = vzalloc(
157 FIFO_PROFILING_ENTRIES * 158 FIFO_PROFILING_ENTRIES *
158 sizeof(struct fifo_profile_gk20a)); 159 sizeof(struct fifo_profile_gk20a));
@@ -165,7 +166,7 @@ static int gk20a_fifo_profile_enable(void *data, u64 val)
165 nvgpu_mutex_release(&f->profile.lock); 166 nvgpu_mutex_release(&f->profile.lock);
166 return -ENOMEM; 167 return -ENOMEM;
167 } 168 }
168 kref_init(&f->profile.ref); 169 nvgpu_ref_init(&f->profile.ref);
169 } 170 }
170 atomic_set(&f->profile.get.atomic_var, 0); 171 atomic_set(&f->profile.get.atomic_var, 0);
171 f->profile.enabled = true; 172 f->profile.enabled = true;
@@ -241,7 +242,7 @@ static int gk20a_fifo_profile_stats(struct seq_file *s, void *unused)
241 u64 percentiles_append[PERCENTILE_RANGES]; 242 u64 percentiles_append[PERCENTILE_RANGES];
242 u64 percentiles_userd[PERCENTILE_RANGES]; 243 u64 percentiles_userd[PERCENTILE_RANGES];
243 244
244 if (!kref_get_unless_zero(&g->fifo.profile.ref)) { 245 if (!nvgpu_ref_get_unless_zero(&g->fifo.profile.ref)) {
245 seq_printf(s, "Profiling disabled\n"); 246 seq_printf(s, "Profiling disabled\n");
246 return 0; 247 return 0;
247 } 248 }
@@ -271,7 +272,7 @@ static int gk20a_fifo_profile_stats(struct seq_file *s, void *unused)
271 percentiles_jobtracking[index], 272 percentiles_jobtracking[index],
272 percentiles_userd[index]); 273 percentiles_userd[index]);
273 274
274 kref_put(&g->fifo.profile.ref, __gk20a_fifo_profile_free); 275 nvgpu_ref_put(&g->fifo.profile.ref, __gk20a_fifo_profile_free);
275 276
276 return 0; 277 return 0;
277} 278}
@@ -312,7 +313,7 @@ void gk20a_fifo_debugfs_init(struct gk20a *g)
312 nvgpu_mutex_init(&g->fifo.profile.lock); 313 nvgpu_mutex_init(&g->fifo.profile.lock);
313 g->fifo.profile.enabled = false; 314 g->fifo.profile.enabled = false;
314 atomic_set(&g->fifo.profile.get.atomic_var, 0); 315 atomic_set(&g->fifo.profile.get.atomic_var, 0);
315 atomic_set(&g->fifo.profile.ref.refcount, 0); 316 atomic_set(&g->fifo.profile.ref.refcount.atomic_var, 0);
316 317
317 debugfs_create_file("enable", 0600, profile_root, g, 318 debugfs_create_file("enable", 0600, profile_root, g,
318 &gk20a_fifo_profile_enable_debugfs_fops); 319 &gk20a_fifo_profile_enable_debugfs_fops);
@@ -322,7 +323,7 @@ void gk20a_fifo_debugfs_init(struct gk20a *g)
322 323
323} 324}
324 325
325void __gk20a_fifo_profile_free(struct kref *ref) 326void __gk20a_fifo_profile_free(struct nvgpu_ref *ref)
326{ 327{
327 struct fifo_gk20a *f = container_of(ref, struct fifo_gk20a, 328 struct fifo_gk20a *f = container_of(ref, struct fifo_gk20a,
328 profile.ref); 329 profile.ref);
@@ -340,7 +341,7 @@ struct fifo_profile_gk20a *gk20a_fifo_profile_acquire(struct gk20a *g)
340 unsigned int index; 341 unsigned int index;
341 342
342 /* If kref is zero, profiling is not enabled */ 343 /* If kref is zero, profiling is not enabled */
343 if (!kref_get_unless_zero(&f->profile.ref)) 344 if (!nvgpu_ref_get_unless_zero(&f->profile.ref))
344 return NULL; 345 return NULL;
345 index = atomic_inc_return(&f->profile.get.atomic_var); 346 index = atomic_inc_return(&f->profile.get.atomic_var);
346 profile = &f->profile.data[index % FIFO_PROFILING_ENTRIES]; 347 profile = &f->profile.data[index % FIFO_PROFILING_ENTRIES];
@@ -352,7 +353,7 @@ struct fifo_profile_gk20a *gk20a_fifo_profile_acquire(struct gk20a *g)
352void gk20a_fifo_profile_release(struct gk20a *g, 353void gk20a_fifo_profile_release(struct gk20a *g,
353 struct fifo_profile_gk20a *profile) 354 struct fifo_profile_gk20a *profile)
354{ 355{
355 kref_put(&g->fifo.profile.ref, __gk20a_fifo_profile_free); 356 nvgpu_ref_put(&g->fifo.profile.ref, __gk20a_fifo_profile_free);
356} 357}
357 358
358void gk20a_fifo_debugfs_deinit(struct gk20a *g) 359void gk20a_fifo_debugfs_deinit(struct gk20a *g)
@@ -362,7 +363,7 @@ void gk20a_fifo_debugfs_deinit(struct gk20a *g)
362 nvgpu_mutex_acquire(&f->profile.lock); 363 nvgpu_mutex_acquire(&f->profile.lock);
363 if (f->profile.enabled) { 364 if (f->profile.enabled) {
364 f->profile.enabled = false; 365 f->profile.enabled = false;
365 kref_put(&f->profile.ref, __gk20a_fifo_profile_free); 366 nvgpu_ref_put(&f->profile.ref, __gk20a_fifo_profile_free);
366 } 367 }
367 nvgpu_mutex_release(&f->profile.lock); 368 nvgpu_mutex_release(&f->profile.lock);
368} 369}