From: Zihao Mu <[email protected]> A new table is linked to the VM before it is cleared. If clearing fails, the allocation path only unpins and drops the BO reference, leaving the entry, VM status list and accounting referring to that BO.
Unwind the initialized entry through amdgpu_vm_pt_free() instead. Finish any partial SDMA clear before returning its original error, so no current job is abandoned. The tracked completion and reservation fences retain the submitted work while TTM handles the BO release. Keep this initialization-error fix separate from the update-phase boundary changes. PDE iteration and its error policy are not changed. Signed-off-by: Zihao Mu <[email protected]> --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c index 9955be111ce..bdd06b7718c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c @@ -372,7 +372,7 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm, struct amdgpu_bo *bo = &vmbo->bo; uint64_t value = 0, flags = 0; uint64_t addr; - int r, idx; + int r, commit_r, idx; /* Figure out our place in the hierarchy */ if (ancestor->parent) { @@ -426,10 +426,9 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm, r = vm->update_funcs->update(¶ms, vmbo, addr, 0, entries, value, flags); - if (r) - goto exit; - - r = vm->update_funcs->commit(¶ms, &vm->last_update); + commit_r = vm->update_funcs->commit(¶ms, &vm->last_update); + if (!r) + r = commit_r; exit: if (last_update && params.last_update) swap(*last_update, params.last_update); @@ -507,6 +506,8 @@ int amdgpu_vm_pt_create(struct amdgpu_device *adev, struct amdgpu_vm *vm, return 0; } +static void amdgpu_vm_pt_free(struct amdgpu_vm_bo_base *entry); + /** * amdgpu_vm_pt_alloc - Allocate a specific page table * @@ -550,8 +551,10 @@ static int amdgpu_vm_pt_alloc(struct amdgpu_vm_update_params *p, amdgpu_vm_bo_base_init(entry, p->vm, pt_bo); r = amdgpu_vm_pt_clear(p->adev, p->vm, pt, p->immediate, &p->last_update); - if (r) - goto error_unpin; + if (r) { + amdgpu_vm_pt_free(entry); + return r; + } return 0; -- 2.43.0
