From: Zihao Mu <[email protected]> Commit the current phase before dropping the eviction lock to allocate a page table. After clearing the new table, prepare another phase with the original sync and the context's original job ID.
The eviction lock prevents table movement during a prepared phase. pt_alloc() drops that lock for allocation, so it must end the phase first. pt_clear() validates the new table before its own prepare; the outer prepare then covers move dependencies before resumed writes. All these submissions preserve immediate and use the same entity. Finish the nested clear's current job even if its update fails, keeping the original error. An empty job is freed by commit; a submitted clear completion is already transferred to the range context for finalization. Keep an initialized table installed if the outer prepare fails. Failed initialization uses the existing teardown prerequisite, rather than introducing another copy of that fix here. Existing tables still return without ending or restarting the current phase. Signed-off-by: Zihao Mu <[email protected]> --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 8 ++++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 3f3c5a82fc1..df65e02bfa2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -1204,6 +1204,7 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm, params.vm = vm; params.immediate = immediate; params.pages_addr = pages_addr; + params.sync = sync; params.unlocked = unlocked; params.needs_flush = flush_tlb; params.override_pte = allow_override && adev->gmc.override_pte; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h index 9bd71f4d5b9..cdf14f69376 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h @@ -87,6 +87,11 @@ struct amdgpu_vm_update_params { */ struct dma_fence *last_update; + /** + * @sync: original dependencies to preserve across prepare calls + */ + struct amdgpu_sync *sync; + /** * @num_dw_left: number of dw left for the IB */ diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c index 7b7a576d95f..1a2352c8c8c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c @@ -426,9 +426,6 @@ 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; - vm->update_funcs->commit(¶ms, &vm->last_update); exit: if (last_update && params.last_update) @@ -532,6 +529,9 @@ static int amdgpu_vm_pt_alloc(struct amdgpu_vm_update_params *p, if (entry->bo) return 0; + /* Allocation can add move dependencies while the lock is dropped. */ + p->vm->update_funcs->commit(p, NULL); + amdgpu_vm_end_critical(p); r = amdgpu_vm_pt_create(p->adev, p->vm, cursor->level, p->immediate, &pt, p->vm->root.bo->xcp_id); @@ -558,7 +558,7 @@ static int amdgpu_vm_pt_alloc(struct amdgpu_vm_update_params *p, return r; } - return 0; + return p->vm->update_funcs->prepare(p, p->sync); error_unpin: if (p->vm->is_npa) -- 2.43.0
