summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/clk
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/clk
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/clk')
-rw-r--r--drivers/gpu/nvgpu/clk/clk_arb.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/drivers/gpu/nvgpu/clk/clk_arb.c b/drivers/gpu/nvgpu/clk/clk_arb.c
index f1de54c6..fc6d403e 100644
--- a/drivers/gpu/nvgpu/clk/clk_arb.c
+++ b/drivers/gpu/nvgpu/clk/clk_arb.c
@@ -61,8 +61,8 @@ static long nvgpu_clk_arb_ioctl_event_dev(struct file *filp, unsigned int cmd,
61static void nvgpu_clk_arb_run_arbiter_cb(struct work_struct *work); 61static void nvgpu_clk_arb_run_arbiter_cb(struct work_struct *work);
62static void nvgpu_clk_arb_run_vf_table_cb(struct work_struct *work); 62static void nvgpu_clk_arb_run_vf_table_cb(struct work_struct *work);
63static int nvgpu_clk_arb_update_vf_table(struct nvgpu_clk_arb *arb); 63static int nvgpu_clk_arb_update_vf_table(struct nvgpu_clk_arb *arb);
64static void nvgpu_clk_arb_free_fd(struct kref *refcount); 64static void nvgpu_clk_arb_free_fd(struct nvgpu_ref *refcount);
65static void nvgpu_clk_arb_free_session(struct kref *refcount); 65static void nvgpu_clk_arb_free_session(struct nvgpu_ref *refcount);
66static int nvgpu_clk_arb_change_vf_point(struct gk20a *g, u16 gpc2clk_target, 66static int nvgpu_clk_arb_change_vf_point(struct gk20a *g, u16 gpc2clk_target,
67 u16 sys2clk_target, u16 xbar2clk_target, u16 mclk_target, u32 voltuv, 67 u16 sys2clk_target, u16 xbar2clk_target, u16 mclk_target, u32 voltuv,
68 u32 voltuv_sram); 68 u32 voltuv_sram);
@@ -214,13 +214,13 @@ struct nvgpu_clk_dev {
214 nvgpu_atomic_t enabled_mask; 214 nvgpu_atomic_t enabled_mask;
215 struct nvgpu_clk_notification_queue queue; 215 struct nvgpu_clk_notification_queue queue;
216 u32 arb_queue_head; 216 u32 arb_queue_head;
217 struct kref refcount; 217 struct nvgpu_ref refcount;
218}; 218};
219 219
220struct nvgpu_clk_session { 220struct nvgpu_clk_session {
221 bool zombie; 221 bool zombie;
222 struct gk20a *g; 222 struct gk20a *g;
223 struct kref refcount; 223 struct nvgpu_ref refcount;
224 struct list_head link; 224 struct list_head link;
225 struct llist_head targets; 225 struct llist_head targets;
226 226
@@ -541,9 +541,9 @@ static int nvgpu_clk_arb_install_fd(struct gk20a *g,
541 nvgpu_atomic_set(&dev->poll_mask, 0); 541 nvgpu_atomic_set(&dev->poll_mask, 0);
542 542
543 dev->session = session; 543 dev->session = session;
544 kref_init(&dev->refcount); 544 nvgpu_ref_init(&dev->refcount);
545 545
546 kref_get(&session->refcount); 546 nvgpu_ref_get(&session->refcount);
547 547
548 *_dev = dev; 548 *_dev = dev;
549 549
@@ -573,7 +573,7 @@ int nvgpu_clk_arb_init_session(struct gk20a *g,
573 return -ENOMEM; 573 return -ENOMEM;
574 session->g = g; 574 session->g = g;
575 575
576 kref_init(&session->refcount); 576 nvgpu_ref_init(&session->refcount);
577 577
578 session->zombie = false; 578 session->zombie = false;
579 session->target_pool[0].pstate = CTRL_PERF_PSTATE_P8; 579 session->target_pool[0].pstate = CTRL_PERF_PSTATE_P8;
@@ -593,7 +593,7 @@ int nvgpu_clk_arb_init_session(struct gk20a *g,
593 return 0; 593 return 0;
594} 594}
595 595
596static void nvgpu_clk_arb_free_fd(struct kref *refcount) 596static void nvgpu_clk_arb_free_fd(struct nvgpu_ref *refcount)
597{ 597{
598 struct nvgpu_clk_dev *dev = container_of(refcount, 598 struct nvgpu_clk_dev *dev = container_of(refcount,
599 struct nvgpu_clk_dev, refcount); 599 struct nvgpu_clk_dev, refcount);
@@ -602,7 +602,7 @@ static void nvgpu_clk_arb_free_fd(struct kref *refcount)
602 nvgpu_kfree(session->g, dev); 602 nvgpu_kfree(session->g, dev);
603} 603}
604 604
605static void nvgpu_clk_arb_free_session(struct kref *refcount) 605static void nvgpu_clk_arb_free_session(struct nvgpu_ref *refcount)
606{ 606{
607 struct nvgpu_clk_session *session = container_of(refcount, 607 struct nvgpu_clk_session *session = container_of(refcount,
608 struct nvgpu_clk_session, refcount); 608 struct nvgpu_clk_session, refcount);
@@ -621,7 +621,7 @@ static void nvgpu_clk_arb_free_session(struct kref *refcount)
621 621
622 head = llist_del_all(&session->targets); 622 head = llist_del_all(&session->targets);
623 llist_for_each_entry_safe(dev, tmp, head, node) { 623 llist_for_each_entry_safe(dev, tmp, head, node) {
624 kref_put(&dev->refcount, nvgpu_clk_arb_free_fd); 624 nvgpu_ref_put(&dev->refcount, nvgpu_clk_arb_free_fd);
625 } 625 }
626 synchronize_rcu(); 626 synchronize_rcu();
627 nvgpu_kfree(g, session); 627 nvgpu_kfree(g, session);
@@ -635,7 +635,7 @@ void nvgpu_clk_arb_release_session(struct gk20a *g,
635 gk20a_dbg_fn(""); 635 gk20a_dbg_fn("");
636 636
637 session->zombie = true; 637 session->zombie = true;
638 kref_put(&session->refcount, nvgpu_clk_arb_free_session); 638 nvgpu_ref_put(&session->refcount, nvgpu_clk_arb_free_session);
639 if (arb && arb->update_work_queue) 639 if (arb && arb->update_work_queue)
640 queue_work(arb->update_work_queue, &arb->update_fn_work); 640 queue_work(arb->update_work_queue, &arb->update_fn_work);
641} 641}
@@ -1099,7 +1099,7 @@ static void nvgpu_clk_arb_run_arbiter_cb(struct work_struct *work)
1099 dev->gpc2clk_target_mhz; 1099 dev->gpc2clk_target_mhz;
1100 gpc2clk_set = true; 1100 gpc2clk_set = true;
1101 } 1101 }
1102 kref_get(&dev->refcount); 1102 nvgpu_ref_get(&dev->refcount);
1103 llist_add(&dev->node, &arb->requests); 1103 llist_add(&dev->node, &arb->requests);
1104 } 1104 }
1105 /* Ensure target is updated before ptr sawp */ 1105 /* Ensure target is updated before ptr sawp */
@@ -1305,7 +1305,7 @@ exit_arb:
1305 llist_for_each_entry_safe(dev, tmp, head, node) { 1305 llist_for_each_entry_safe(dev, tmp, head, node) {
1306 nvgpu_atomic_set(&dev->poll_mask, POLLIN | POLLRDNORM); 1306 nvgpu_atomic_set(&dev->poll_mask, POLLIN | POLLRDNORM);
1307 wake_up_interruptible(&dev->readout_wq); 1307 wake_up_interruptible(&dev->readout_wq);
1308 kref_put(&dev->refcount, nvgpu_clk_arb_free_fd); 1308 nvgpu_ref_put(&dev->refcount, nvgpu_clk_arb_free_fd);
1309 } 1309 }
1310 1310
1311 nvgpu_atomic_set(&arb->notification_queue.head, 1311 nvgpu_atomic_set(&arb->notification_queue.head,
@@ -1523,7 +1523,7 @@ int nvgpu_clk_arb_commit_request_fd(struct gk20a *g,
1523 err = -EINVAL; 1523 err = -EINVAL;
1524 goto fdput_fd; 1524 goto fdput_fd;
1525 } 1525 }
1526 kref_get(&dev->refcount); 1526 nvgpu_ref_get(&dev->refcount);
1527 llist_add(&dev->node, &session->targets); 1527 llist_add(&dev->node, &session->targets);
1528 if (arb->update_work_queue) 1528 if (arb->update_work_queue)
1529 queue_work(arb->update_work_queue, &arb->update_fn_work); 1529 queue_work(arb->update_work_queue, &arb->update_fn_work);
@@ -1607,8 +1607,8 @@ static int nvgpu_clk_arb_release_completion_dev(struct inode *inode,
1607 1607
1608 gk20a_dbg_fn(""); 1608 gk20a_dbg_fn("");
1609 1609
1610 kref_put(&session->refcount, nvgpu_clk_arb_free_session); 1610 nvgpu_ref_put(&session->refcount, nvgpu_clk_arb_free_session);
1611 kref_put(&dev->refcount, nvgpu_clk_arb_free_fd); 1611 nvgpu_ref_put(&dev->refcount, nvgpu_clk_arb_free_fd);
1612 return 0; 1612 return 0;
1613} 1613}
1614 1614
@@ -1631,8 +1631,8 @@ static int nvgpu_clk_arb_release_event_dev(struct inode *inode,
1631 } 1631 }
1632 1632
1633 synchronize_rcu(); 1633 synchronize_rcu();
1634 kref_put(&session->refcount, nvgpu_clk_arb_free_session); 1634 nvgpu_ref_put(&session->refcount, nvgpu_clk_arb_free_session);
1635 kref_put(&dev->refcount, nvgpu_clk_arb_free_fd); 1635 nvgpu_ref_put(&dev->refcount, nvgpu_clk_arb_free_fd);
1636 1636
1637 return 0; 1637 return 0;
1638} 1638}