From: Yu Huang <[email protected]> When the walk stops at a PTB that has its own BO allocated, the update was still aimed at cursor.parent->bo using the parent's shift and mask. That writes a PDE in the parent table instead of the PTEs in the leaf table the cursor actually reached, so the intended leaves are never touched.
Target the entry's BO with its own level whenever the cursor sits on an allocated AMDGPU_VM_PTB, and keep the parent for every other level. Also go through amdgpu_vm_pte_update_flags() rather than calling update_funcs->update() directly, so the flags are adjusted for the level being written instead of being passed through verbatim. Signed-off-by: Yu Huang <[email protected]> Change-Id: I5e3f4a1803c6a1bac10677f48f273a4ad711d760 --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c index ec7bdec1a3a7..d97e790396bf 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c @@ -951,9 +951,16 @@ void amdgpu_vm_pt_leaves(struct amdgpu_vm_update_params *params, if (amdgpu_vm_pt_descendant(adev, &cursor)) continue; - pt = cursor.parent->bo; - shift = amdgpu_vm_pt_level_shift(adev, cursor.level - 1); - mask = amdgpu_vm_pt_entries_mask(adev, cursor.level - 1); + if (cursor.level == AMDGPU_VM_PTB && cursor.entry && + cursor.entry->bo) { + pt = cursor.entry->bo; + shift = amdgpu_vm_pt_level_shift(adev, cursor.level); + mask = amdgpu_vm_pt_entries_mask(adev, cursor.level); + } else { + pt = cursor.parent->bo; + shift = amdgpu_vm_pt_level_shift(adev, cursor.level - 1); + mask = amdgpu_vm_pt_entries_mask(adev, cursor.level - 1); + } /* Looks good so far, calculate parameters for the update */ pe_start = ((cursor.pfn >> shift) & mask) * 8; @@ -973,9 +980,11 @@ void amdgpu_vm_pt_leaves(struct amdgpu_vm_update_params *params, trace_amdgpu_vm_update_ptes(params, cursor.pfn, entry_end, min(nptes, 32u), val, 0, flags); - params->vm->update_funcs->update(params, to_amdgpu_bo_vm(pt), - pe_start, val, nptes, 0, - flags); + amdgpu_vm_pte_update_flags(params, to_amdgpu_bo_vm(pt), + pt == cursor.parent->bo ? + cursor.level - 1 : + cursor.level, + pe_start, val, nptes, 0, flags); amdgpu_vm_pt_next(adev, &cursor); } } -- 2.53.0
