]> 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)
committerJuha Tukkinen <jtukkinen@nvidia.com>
Tue, 18 Mar 2014 06:45:50 +0000 (23:45 -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
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Juha Tukkinen <jtukkinen@nvidia.com>
drivers/video/tegra/host/gk20a/gr_gk20a.c
drivers/video/tegra/host/gk20a/mm_gk20a.c

index 3116029872561d56e6a1b282bfa0be110b56c91b..afb6848b46543b56ecb3f13c42af5c22f1f62fe1 100644 (file)
@@ -2559,6 +2559,9 @@ static void gr_gk20a_free_channel_gr_ctx(struct channel_gk20a *c)
 
        gk20a_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, gk20a_mem_flag_none);
        dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &attrs);
index 1c61efc9787feb8a86b6875c8a8a9a6b8abb33cc..bd253bea54054d1ce1f17b8cb0b4b657ee549741 100644 (file)
@@ -837,7 +837,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)
 {
@@ -859,6 +859,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,
@@ -1124,8 +1126,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,