7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jesse Zhang [ Upstream commit 71388e1ed836d7645b4807cead35edf24da00bcd ] amdgpu_vm_bo_reset_state_machine() moves all idle vm_bos to needs_update so that their mappings are written again, e.g. after a GPU reset lost VRAM. Since commit 5be7f6720a0f ("drm/amdgpu: Only set bo->moved when the BO was actually moved") amdgpu_vm_bo_needs_update() no longer sets the moved flag, so amdgpu_vm_bo_update() writes nothing for the kernel and always valid BOs. The same applies to vm_bos already on a needs_update list, e.g. after an AMDGPU_VM_DELAY_UPDATE mapping, where only the new mapping gets written. An SDMA write to an always valid BO after a VRAM-losing reset faults: amdgpu 0000:03:00.0: VRAM is lost due to GPU reset! amdgpu 0000:03:00.0: [gfxhub] page fault (src_id:0 ring:40 vmid:7 pasid:9) amdgpu 0000:03:00.0: in page starting at address 0x0000000100000000 from client 10 Set the moved flag for all vm_bos on the needs_update lists after moving the idle ones there; the root PD still goes back to idle. Fixes: 5be7f6720a0f ("drm/amdgpu: Only set bo->moved when the BO was actually moved") Reviewed-by: Christian König Signed-off-by: Jesse Zhang Signed-off-by: Alex Deucher (cherry picked from commit d397f95f63cc0f711c3e8f2043edc59b575345ab) Cc: stable@vger.kernel.org Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index fc3a8d38d5149..c07f1115f6543 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -269,19 +269,27 @@ static void amdgpu_vm_bo_reset_state_machine(struct amdgpu_vm *vm) /* * Don't use list splice here, we need the special handling for the root - * PD and set the moved flag appropriately. + * PD. All mappings must be written again, also of the vm_bos which are + * already waiting for an update of some of them, e.g. after a map with + * a delayed update, so set the moved flag for everything that needs an + * update. */ amdgpu_vm_assert_locked(vm); list_for_each_entry_safe(vm_bo, tmp, &vm->kernel.idle, vm_status) amdgpu_vm_bo_needs_update(vm_bo); + list_for_each_entry(vm_bo, &vm->kernel.needs_update, vm_status) + vm_bo->moved = true; + list_for_each_entry_safe(vm_bo, tmp, &vm->always_valid.idle, vm_status) amdgpu_vm_bo_needs_update(vm_bo); + list_for_each_entry(vm_bo, &vm->always_valid.needs_update, vm_status) + vm_bo->moved = true; spin_lock(&vm->individual_lock); - list_for_each_entry_safe(vm_bo, tmp, &vm->individual.idle, vm_status) { - vm_bo->moved = true; + list_for_each_entry_safe(vm_bo, tmp, &vm->individual.idle, vm_status) list_move(&vm_bo->vm_status, &vm->individual.needs_update); - } + list_for_each_entry(vm_bo, &vm->individual.needs_update, vm_status) + vm_bo->moved = true; spin_unlock(&vm->individual_lock); } -- 2.53.0