Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/amdgpu: fix error handling in amdgpu_vm_init

When clearing the root PD fails we need to properly release it again.

Signed-off-by: Christian König <christian.koenig@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org

authored by

Christian König and committed by
Alex Deucher
8473bfdc 25650307

+17 -16
+17 -16
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
··· 2139 2139 * Returns: 2140 2140 * 0 for success, error for failure. 2141 2141 */ 2142 - int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, int32_t xcp_id) 2142 + int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, 2143 + int32_t xcp_id) 2143 2144 { 2144 2145 struct amdgpu_bo *root_bo; 2145 2146 struct amdgpu_bo_vm *root; ··· 2159 2158 INIT_LIST_HEAD(&vm->done); 2160 2159 INIT_LIST_HEAD(&vm->pt_freed); 2161 2160 INIT_WORK(&vm->pt_free_work, amdgpu_vm_pt_free_work); 2161 + INIT_KFIFO(vm->faults); 2162 2162 2163 2163 r = amdgpu_vm_init_entities(adev, vm); 2164 2164 if (r) ··· 2194 2192 false, &root, xcp_id); 2195 2193 if (r) 2196 2194 goto error_free_delayed; 2197 - root_bo = &root->bo; 2195 + 2196 + root_bo = amdgpu_bo_ref(&root->bo); 2198 2197 r = amdgpu_bo_reserve(root_bo, true); 2198 + if (r) { 2199 + amdgpu_bo_unref(&root->shadow); 2200 + amdgpu_bo_unref(&root_bo); 2201 + goto error_free_delayed; 2202 + } 2203 + 2204 + amdgpu_vm_bo_base_init(&vm->root, vm, root_bo); 2205 + r = dma_resv_reserve_fences(root_bo->tbo.base.resv, 1); 2199 2206 if (r) 2200 2207 goto error_free_root; 2201 2208 2202 - r = dma_resv_reserve_fences(root_bo->tbo.base.resv, 1); 2203 - if (r) 2204 - goto error_unreserve; 2205 - 2206 - amdgpu_vm_bo_base_init(&vm->root, vm, root_bo); 2207 - 2208 2209 r = amdgpu_vm_pt_clear(adev, vm, root, false); 2209 2210 if (r) 2210 - goto error_unreserve; 2211 + goto error_free_root; 2211 2212 2212 2213 amdgpu_bo_unreserve(vm->root.bo); 2213 - 2214 - INIT_KFIFO(vm->faults); 2214 + amdgpu_bo_unref(&root_bo); 2215 2215 2216 2216 return 0; 2217 2217 2218 - error_unreserve: 2219 - amdgpu_bo_unreserve(vm->root.bo); 2220 - 2221 2218 error_free_root: 2222 - amdgpu_bo_unref(&root->shadow); 2219 + amdgpu_vm_pt_free_root(adev, vm); 2220 + amdgpu_bo_unreserve(vm->root.bo); 2223 2221 amdgpu_bo_unref(&root_bo); 2224 - vm->root.bo = NULL; 2225 2222 2226 2223 error_free_delayed: 2227 2224 dma_fence_put(vm->last_tlb_flush);