@@ -2139,7 +2139,8 @@ long amdgpu_vm_wait_idle(struct amdgpu_vm *vm, long timeout)
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 ;
@@ -2158,6 +2159,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, int32_t xcp
2158
2159
INIT_LIST_HEAD (& vm -> done );
2159
2160
INIT_LIST_HEAD (& vm -> pt_freed );
2160
2161
INIT_WORK (& vm -> pt_free_work , amdgpu_vm_pt_free_work );
2162
+ INIT_KFIFO (vm -> faults );
2161
2163
2162
2164
r = amdgpu_vm_init_entities (adev , vm );
2163
2165
if (r )
@@ -2192,34 +2194,33 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, int32_t xcp
2192
2194
false, & root , xcp_id );
2193
2195
if (r )
2194
2196
goto error_free_delayed ;
2195
- root_bo = & root -> bo ;
2197
+
2198
+ root_bo = amdgpu_bo_ref (& root -> bo );
2196
2199
r = amdgpu_bo_reserve (root_bo , true);
2197
- if (r )
2198
- goto error_free_root ;
2200
+ if (r ) {
2201
+ amdgpu_bo_unref (& root -> shadow );
2202
+ amdgpu_bo_unref (& root_bo );
2203
+ goto error_free_delayed ;
2204
+ }
2199
2205
2206
+ amdgpu_vm_bo_base_init (& vm -> root , vm , root_bo );
2200
2207
r = dma_resv_reserve_fences (root_bo -> tbo .base .resv , 1 );
2201
2208
if (r )
2202
- goto error_unreserve ;
2203
-
2204
- amdgpu_vm_bo_base_init (& vm -> root , vm , root_bo );
2209
+ goto error_free_root ;
2205
2210
2206
2211
r = amdgpu_vm_pt_clear (adev , vm , root , false);
2207
2212
if (r )
2208
- goto error_unreserve ;
2213
+ goto error_free_root ;
2209
2214
2210
2215
amdgpu_bo_unreserve (vm -> root .bo );
2211
-
2212
- INIT_KFIFO (vm -> faults );
2216
+ amdgpu_bo_unref (& root_bo );
2213
2217
2214
2218
return 0 ;
2215
2219
2216
- error_unreserve :
2217
- amdgpu_bo_unreserve (vm -> root .bo );
2218
-
2219
2220
error_free_root :
2220
- amdgpu_bo_unref (& root -> shadow );
2221
+ amdgpu_vm_pt_free_root (adev , vm );
2222
+ amdgpu_bo_unreserve (vm -> root .bo );
2221
2223
amdgpu_bo_unref (& root_bo );
2222
- vm -> root .bo = NULL ;
2223
2224
2224
2225
error_free_delayed :
2225
2226
dma_fence_put (vm -> last_tlb_flush );
0 commit comments