From: zihaomu <[email protected]> Hello Alex, Christian and Cascardo,
I would like guidance on propagating PTE backend update errors and how that should interact with the no-fail unmap contract. At drm-amdgpu-next commit 5349075eac14, the void helper amdgpu_vm_pte_update_flags() calls update_funcs->update() but drops its int return value. The CPU backend can report an interrupted fence wait; the SDMA backend can report a dependency or replacement-job allocation failure. The PTE walker can then advance past unwritten entries, invoke the backend again, and return success for an incomplete mapping. The illustrative diff below returns that error and stops the walker. It is not a complete fix for merging: propagating failures also needs correct finalization of partially written PTEs, pending SDMA work, TLB handling and the stack-local tlb_flush_waitlist. The local RFC has two cleanup prerequisites adapted from Cascardo's September series [1]: handle missing/empty SDMA jobs, and finish partial range updates while preserving the original error. The ignored backend return was also raised by Sashiko in that discussion [2]. I am not claiming the earlier cleanup work or the observation as new. I have excluded the earlier mapping-retention proposal, which Christian explicitly NAKed [3]. amdgpu_vm_clear_freed() remains unchanged, and a KFD caller still discards its result. The remaining contract questions are therefore important before proposing this for merging: 1. Should errors during clear/unmap be prevented or completed inside the backend before the PTE walker can propagate failures? 2. Is there a current map/unmap split or successor series that this work should be based on? On the native base above, isolated models using extracted functions passed 5 PTE, 17 range/finalization and 2 SDMA ownership scenarios, including baseline failure and deliberately broken controls, with no ASan/UBSan reports. GCC 13.3.0 compiled amdgpu_vm.o, amdgpu_vm_pt.o and amdgpu_vm_sdma.o with CONFIG_DRM_AMDGPU=m. These are modeled errors and object builds, not live kernel fault injection or hardware validation. There is no claim that this resolves the original GPU queue stalls. For background, the earlier vendor-tree PR is [4]. Its four commits are not the proposed native submission, and the independent CPU fence scan optimization is outside this discussion. [1] https://www.mail-archive.com/[email protected]/msg635900.html [2] https://www.mail-archive.com/[email protected]/msg635904.html [3] https://www.mail-archive.com/[email protected]/msg638593.html [4] https://github.com/ROCm/amdgpu/pull/243 Signed-off-by: zihaomu <[email protected]> --- Illustrative error-propagation diff only; cleanup prerequisites and agreement on the unmap failure contract are still required. diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c index c73eb416c0e2..d9cfced93081 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c @@ -701,12 +701,12 @@ static void amdgpu_vm_pte_update_noretry_flags(struct amdgpu_device *adev, * * Make sure to set the right flags for the PTEs at the desired level. */ -static void amdgpu_vm_pte_update_flags(struct amdgpu_vm_update_params *params, - struct amdgpu_bo_vm *pt, - unsigned int level, - uint64_t pe, uint64_t addr, - unsigned int count, uint32_t incr, - uint64_t flags) +static int amdgpu_vm_pte_update_flags(struct amdgpu_vm_update_params *params, + struct amdgpu_bo_vm *pt, + unsigned int level, + u64 pe, u64 addr, + unsigned int count, u32 incr, + u64 flags) { struct amdgpu_device *adev = params->adev; @@ -735,8 +735,8 @@ static void amdgpu_vm_pte_update_flags(struct amdgpu_vm_update_params *params, if (level == AMDGPU_VM_PTB) amdgpu_vm_pte_update_noretry_flags(adev, &flags); - params->vm->update_funcs->update(params, pt, pe, addr, count, incr, - flags); + return params->vm->update_funcs->update(params, pt, pe, addr, count, incr, + flags); } /** @@ -812,7 +812,7 @@ static void amdgpu_vm_pte_fragment(struct amdgpu_vm_update_params *params, * Update the page tables in the range @start - @end. * * Returns: - * 0 for success, -EINVAL for failure. + * 0 for success, negative errno for failure. */ int amdgpu_vm_ptes_update(struct amdgpu_vm_update_params *params, uint64_t start, uint64_t end, @@ -921,9 +921,11 @@ int amdgpu_vm_ptes_update(struct amdgpu_vm_update_params *params, trace_amdgpu_vm_update_ptes(params, frag_start, upd_end, min(nptes, 32u), dst, incr, upd_flags); - amdgpu_vm_pte_update_flags(params, to_amdgpu_bo_vm(pt), - cursor.level, pe_start, dst, - nptes, incr, upd_flags); + r = amdgpu_vm_pte_update_flags(params, to_amdgpu_bo_vm(pt), + cursor.level, pe_start, dst, + nptes, incr, upd_flags); + if (r) + return r; pe_start += nptes * 8; dst += nptes * incr; -- 2.43.0
