summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2016-11-29 19:01:41 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2017-02-07 17:54:02 -0500
commit7e403974d3584ab8880e42d422ee3afb7f49d6f3 (patch)
tree9103e53336d8ec70f81acab5d39c9da2107abd2e /drivers/gpu/nvgpu/gk20a/mm_gk20a.c
parent07f07981733135f648c53acfedf03b43045fed08 (diff)
gpu: nvgpu: Simplify ref-counting on VMs
Simplify ref-counting on VMs: take a ref when a VM is bound to a channel and drop a ref when a channel is freed. Previously ref-counts were scattered over the driver. Also the CE and CDE code would bind channels with custom rolled code. This was because the gk20a_vm_bind_channel() function took an as_share as the VM argument (the VM was then inferred from that as_share). However, it is trivial to abtract that bit out and allow a central bind channel function that just takes a VM and a channel. Bug 1846718 Change-Id: I156aab259f6c7a2fa338408c6c4a3a464cd44a0c Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: http://git-master/r/1261886 Reviewed-by: Richard Zhao <rizhao@nvidia.com> Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/mm_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/mm_gk20a.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
index e589e312..ea5ea73f 100644
--- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
@@ -4199,10 +4199,8 @@ static int gk20a_init_sema_pool(struct vm_gk20a *vm)
4199 return -ENOMEM; 4199 return -ENOMEM;
4200 4200
4201 vm->sema_pool = gk20a_semaphore_pool_alloc(sema_sea); 4201 vm->sema_pool = gk20a_semaphore_pool_alloc(sema_sea);
4202 if (!vm->sema_pool) { 4202 if (!vm->sema_pool)
4203 gk20a_vm_put(vm);
4204 return -ENOMEM; 4203 return -ENOMEM;
4205 }
4206 4204
4207 /* 4205 /*
4208 * Allocate a chunk of GPU VA space for mapping the semaphores. We will 4206 * Allocate a chunk of GPU VA space for mapping the semaphores. We will
@@ -4227,7 +4225,7 @@ static int gk20a_init_sema_pool(struct vm_gk20a *vm)
4227 gk20a_semaphore_pool_unmap(vm->sema_pool, vm); 4225 gk20a_semaphore_pool_unmap(vm->sema_pool, vm);
4228 nvgpu_free(vm->vma[gmmu_page_size_small], 4226 nvgpu_free(vm->vma[gmmu_page_size_small],
4229 vm->sema_pool->gpu_va); 4227 vm->sema_pool->gpu_va);
4230 gk20a_vm_put(vm); 4228 return err;
4231 } 4229 }
4232 4230
4233 return 0; 4231 return 0;
@@ -4632,12 +4630,10 @@ int gk20a_vm_release_share(struct gk20a_as_share *as_share)
4632 gk20a_dbg_fn(""); 4630 gk20a_dbg_fn("");
4633 4631
4634 vm->as_share = NULL; 4632 vm->as_share = NULL;
4633 as_share->vm = NULL;
4635 4634
4636 /* put as reference to vm */
4637 gk20a_vm_put(vm); 4635 gk20a_vm_put(vm);
4638 4636
4639 as_share->vm = NULL;
4640
4641 return 0; 4637 return 0;
4642} 4638}
4643 4639
@@ -4792,14 +4788,13 @@ int gk20a_vm_free_space(struct gk20a_as_share *as_share,
4792 return err; 4788 return err;
4793} 4789}
4794 4790
4795int gk20a_vm_bind_channel(struct gk20a_as_share *as_share, 4791int __gk20a_vm_bind_channel(struct vm_gk20a *vm, struct channel_gk20a *ch)
4796 struct channel_gk20a *ch)
4797{ 4792{
4798 int err = 0; 4793 int err = 0;
4799 struct vm_gk20a *vm = as_share->vm;
4800 4794
4801 gk20a_dbg_fn(""); 4795 gk20a_dbg_fn("");
4802 4796
4797 gk20a_vm_get(vm);
4803 ch->vm = vm; 4798 ch->vm = vm;
4804 err = channel_gk20a_commit_va(ch); 4799 err = channel_gk20a_commit_va(ch);
4805 if (err) 4800 if (err)
@@ -4808,6 +4803,12 @@ int gk20a_vm_bind_channel(struct gk20a_as_share *as_share,
4808 return err; 4803 return err;
4809} 4804}
4810 4805
4806int gk20a_vm_bind_channel(struct gk20a_as_share *as_share,
4807 struct channel_gk20a *ch)
4808{
4809 return __gk20a_vm_bind_channel(as_share->vm, ch);
4810}
4811
4811int gk20a_dmabuf_alloc_drvdata(struct dma_buf *dmabuf, struct device *dev) 4812int gk20a_dmabuf_alloc_drvdata(struct dma_buf *dmabuf, struct device *dev)
4812{ 4813{
4813 struct gk20a_dmabuf_priv *priv; 4814 struct gk20a_dmabuf_priv *priv;