summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
diff options
context:
space:
mode:
authorShridhar Rasal <srasal@nvidia.com>2014-04-22 11:45:25 -0400
committerDan Willemsen <dwillemsen@nvidia.com>2015-03-18 15:09:25 -0400
commit8144bf64163f23844bae958fbe4d7df3ccc7c66a (patch)
tree79ace4d806ea8d86292dbf19fa29d256c72f1492 /drivers/gpu/nvgpu/gk20a/mm_gk20a.c
parent270a962c540522bceddbbc41a055b52a65dec489 (diff)
gpu: nvgpu: mm: free allocations on validate error
Free allocated virtual address when marking PTE for validation or update fails. Bug 1479803 Change-Id: I9a8bd7c245b478f4252a261f246002fcc65d750d Signed-off-by: Shridhar Rasal <srasal@nvidia.com> (cherry picked from commit b5c0ad4e00dfc86b65e8efe3d8691b5cfaafbe4c) Reviewed-on: http://git-master/r/415248 Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/mm_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/mm_gk20a.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
index 9de589f9..af7e0b51 100644
--- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
@@ -1103,6 +1103,7 @@ static u64 __locked_gmmu_map(struct vm_gk20a *vm,
1103 int rw_flag) 1103 int rw_flag)
1104{ 1104{
1105 int err = 0, i = 0; 1105 int err = 0, i = 0;
1106 bool allocated = false;
1106 u32 pde_lo, pde_hi; 1107 u32 pde_lo, pde_hi;
1107 struct device *d = dev_from_vm(vm); 1108 struct device *d = dev_from_vm(vm);
1108 1109
@@ -1113,8 +1114,9 @@ static u64 __locked_gmmu_map(struct vm_gk20a *vm,
1113 if (!map_offset) { 1114 if (!map_offset) {
1114 gk20a_err(d, "failed to allocate va space"); 1115 gk20a_err(d, "failed to allocate va space");
1115 err = -ENOMEM; 1116 err = -ENOMEM;
1116 goto fail; 1117 goto fail_alloc;
1117 } 1118 }
1119 allocated = true;
1118 } 1120 }
1119 1121
1120 pde_range_from_vaddr_range(vm, 1122 pde_range_from_vaddr_range(vm,
@@ -1129,7 +1131,7 @@ static u64 __locked_gmmu_map(struct vm_gk20a *vm,
1129 if (err) { 1131 if (err) {
1130 gk20a_err(d, "failed to validate page table %d: %d", 1132 gk20a_err(d, "failed to validate page table %d: %d",
1131 i, err); 1133 i, err);
1132 goto fail; 1134 goto fail_validate;
1133 } 1135 }
1134 } 1136 }
1135 1137
@@ -1143,11 +1145,14 @@ static u64 __locked_gmmu_map(struct vm_gk20a *vm,
1143 rw_flag); 1145 rw_flag);
1144 if (err) { 1146 if (err) {
1145 gk20a_err(d, "failed to update ptes on map"); 1147 gk20a_err(d, "failed to update ptes on map");
1146 goto fail; 1148 goto fail_validate;
1147 } 1149 }
1148 1150
1149 return map_offset; 1151 return map_offset;
1150 fail: 1152fail_validate:
1153 if (allocated)
1154 gk20a_vm_free_va(vm, map_offset, size, pgsz_idx);
1155fail_alloc:
1151 gk20a_err(d, "%s: failed with err=%d\n", __func__, err); 1156 gk20a_err(d, "%s: failed with err=%d\n", __func__, err);
1152 return 0; 1157 return 0;
1153} 1158}