diff options
author | David Nieto <dmartineznie@nvidia.com> | 2017-02-13 14:22:59 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-03-20 19:39:55 -0400 |
commit | 74fe1caa2b56aab24c17ad4dd2524128fc237894 (patch) | |
tree | 0793bb92b67d64690658f3f7cd1a8e1ea93206ba /drivers/gpu/nvgpu/gk20a/sched_gk20a.c | |
parent | 469308becaff326da02fcf791e803e812e1cf9f8 (diff) |
gpu: nvgpu: Add refcounting to driver fds
The main driver structure is not refcounted properly,
so when the driver unload, file desciptors associated to the
driver are kept open with dangling references to the main object.
This change adds referencing to the gk20a structure.
bug 200277762
JIRA: EVLR-1023
Change-Id: Id892e9e1677a344789e99bf649088c076f0bf8de
Signed-off-by: David Nieto <dmartineznie@nvidia.com>
Reviewed-on: http://git-master/r/1317420
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/sched_gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/sched_gk20a.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/sched_gk20a.c b/drivers/gpu/nvgpu/gk20a/sched_gk20a.c index 6fdc2774..a73e7993 100644 --- a/drivers/gpu/nvgpu/gk20a/sched_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/sched_gk20a.c | |||
@@ -377,21 +377,28 @@ int gk20a_sched_dev_open(struct inode *inode, struct file *filp) | |||
377 | { | 377 | { |
378 | struct gk20a *g = container_of(inode->i_cdev, | 378 | struct gk20a *g = container_of(inode->i_cdev, |
379 | struct gk20a, sched.cdev); | 379 | struct gk20a, sched.cdev); |
380 | struct gk20a_sched_ctrl *sched = &g->sched_ctrl; | 380 | struct gk20a_sched_ctrl *sched; |
381 | int err; | 381 | int err = 0; |
382 | |||
383 | g = gk20a_get(g); | ||
384 | if (!g) | ||
385 | return -ENODEV; | ||
386 | sched = &g->sched_ctrl; | ||
382 | 387 | ||
383 | gk20a_dbg(gpu_dbg_fn | gpu_dbg_sched, "g=%p", g); | 388 | gk20a_dbg(gpu_dbg_fn | gpu_dbg_sched, "g=%p", g); |
384 | 389 | ||
385 | if (!sched->sw_ready) { | 390 | if (!sched->sw_ready) { |
386 | err = gk20a_busy(g->dev); | 391 | err = gk20a_busy(g->dev); |
387 | if (err) | 392 | if (err) |
388 | return err; | 393 | goto free_ref; |
389 | 394 | ||
390 | gk20a_idle(g->dev); | 395 | gk20a_idle(g->dev); |
391 | } | 396 | } |
392 | 397 | ||
393 | if (!nvgpu_mutex_tryacquire(&sched->busy_lock)) | 398 | if (!nvgpu_mutex_tryacquire(&sched->busy_lock)) { |
394 | return -EBUSY; | 399 | err = -EBUSY; |
400 | goto free_ref; | ||
401 | } | ||
395 | 402 | ||
396 | memcpy(sched->recent_tsg_bitmap, sched->active_tsg_bitmap, | 403 | memcpy(sched->recent_tsg_bitmap, sched->active_tsg_bitmap, |
397 | sched->bitmap_size); | 404 | sched->bitmap_size); |
@@ -400,7 +407,10 @@ int gk20a_sched_dev_open(struct inode *inode, struct file *filp) | |||
400 | filp->private_data = sched; | 407 | filp->private_data = sched; |
401 | gk20a_dbg(gpu_dbg_sched, "filp=%p sched=%p", filp, sched); | 408 | gk20a_dbg(gpu_dbg_sched, "filp=%p sched=%p", filp, sched); |
402 | 409 | ||
403 | return 0; | 410 | free_ref: |
411 | if (err) | ||
412 | gk20a_put(g); | ||
413 | return err; | ||
404 | } | 414 | } |
405 | 415 | ||
406 | long gk20a_sched_dev_ioctl(struct file *filp, unsigned int cmd, | 416 | long gk20a_sched_dev_ioctl(struct file *filp, unsigned int cmd, |
@@ -511,6 +521,7 @@ int gk20a_sched_dev_release(struct inode *inode, struct file *filp) | |||
511 | nvgpu_mutex_release(&sched->control_lock); | 521 | nvgpu_mutex_release(&sched->control_lock); |
512 | 522 | ||
513 | nvgpu_mutex_release(&sched->busy_lock); | 523 | nvgpu_mutex_release(&sched->busy_lock); |
524 | gk20a_put(g); | ||
514 | return 0; | 525 | return 0; |
515 | } | 526 | } |
516 | 527 | ||