]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: host: gk20a: Check for free va fail
authorTerje Bergstrom <tbergstrom@nvidia.com>
Tue, 4 Mar 2014 13:05:06 +0000 (15:05 +0200)
committerMatthew Pedro <mapedro@nvidia.com>
Thu, 3 Apr 2014 16:55:43 +0000 (09:55 -0700)
Return error if freeing virtual address space fails. Do not try to
free graphics context that has not been allocated.

Change-Id: I1c22650aae25038d56582e00b8906532ace482f1
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/382474
(cherry picked from commit 20a8917aaa7c6bbad3c74f5279fb8b142f858e77)
Reviewed-on: http://git-master/r/391823
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Matthew Pedro <mapedro@nvidia.com>
Tested-by: Matthew Pedro <mapedro@nvidia.com>
drivers/video/tegra/host/gk20a/gr_gk20a.c
drivers/video/tegra/host/gk20a/mm_gk20a.c

index 67ce9b29a75fd0e0f3387ed723d42f9182cad2b6..4caaa51ab1aa488a83aaac325d60ffe532c37a6d 100644 (file)
@@ -2523,6 +2523,9 @@ static void gr_gk20a_free_channel_gr_ctx(struct channel_gk20a *c)
 
        nvhost_dbg_fn("");
 
+       if (!ch_ctx->gr_ctx.gpu_va)
+               return;
+
        gk20a_gmmu_unmap(ch_vm, ch_ctx->gr_ctx.gpu_va,
                        ch_ctx->gr_ctx.size, mem_flag_none);
        dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &attrs);
index 2542dc488ee1e490b723b2669b7b323695a5b084..fdb750ef03be5f5dfa106bf07690f8bb94688e09 100644 (file)
@@ -687,7 +687,7 @@ static u64 gk20a_vm_alloc_va(struct vm_gk20a *vm,
        return offset;
 }
 
-static void gk20a_vm_free_va(struct vm_gk20a *vm,
+static int gk20a_vm_free_va(struct vm_gk20a *vm,
                             u64 offset, u64 size,
                             enum gmmu_pgsz_gk20a pgsz_idx)
 {
@@ -709,6 +709,8 @@ static void gk20a_vm_free_va(struct vm_gk20a *vm,
                           "not found: offset=0x%llx, sz=0x%llx",
                           offset, size);
        }
+
+       return err;
 }
 
 static int insert_mapped_buffer(struct rb_root *root,
@@ -1019,8 +1021,14 @@ static void __locked_gmmu_unmap(struct vm_gk20a *vm,
        int err = 0;
        struct gk20a *g = gk20a_from_vm(vm);
 
-       if (va_allocated)
-               gk20a_vm_free_va(vm, vaddr, size, pgsz_idx);
+       if (va_allocated) {
+               err = gk20a_vm_free_va(vm, vaddr, size, pgsz_idx);
+               if (err) {
+                       dev_err(dev_from_vm(vm),
+                               "failed to free va");
+                       return;
+               }
+       }
 
        /* unmap here needs to know the page size we assigned at mapping */
        err = update_gmmu_ptes_locked(vm,