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>
This commit is contained in:
Alex Waterman
2016-11-29 16:01:41 -08:00
committed by mobile promotions
parent 07f0798173
commit 7e403974d3
6 changed files with 23 additions and 30 deletions

View File

@@ -453,9 +453,7 @@ u32 gk20a_ce_create_context_with_cb(struct device *dev,
}
/* bind the channel to the vm */
gk20a_vm_get(&g->mm.ce.vm);
ce_ctx->vm = ce_ctx->ch->vm = &g->mm.ce.vm;
err = channel_gk20a_commit_va(ce_ctx->ch);
err = __gk20a_vm_bind_channel(&g->mm.ce.vm, ce_ctx->ch);
if (err) {
gk20a_err(ce_ctx->dev, "ce: could not bind vm");
goto end;