Commit 90ca78de authored by Felix Kuehling's avatar Felix Kuehling Committed by Alex Deucher
Browse files

drm/amdgpu: Sync with VM root BO when switching VM to CPU update mode



This fixes an intermittent bug where a root PD clear operation still in
progress could overwrite a PDE update done by the CPU, resulting in a
VM fault.

Fixes: 108b4d92 ("drm/amd/amdgpu: Update VM function pointer")
Reported-by: default avatarJay Cornwall <Jay.Cornwall@amd.com>
Tested-by: default avatarJay Cornwall <Jay.Cornwall@amd.com>
Signed-off-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent cdaae837
Loading
Loading
Loading
Loading
+9 −2
Original line number Original line Diff line number Diff line
@@ -3000,10 +3000,17 @@ int amdgpu_vm_make_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm,
		   !amdgpu_gmc_vram_full_visible(&adev->gmc)),
		   !amdgpu_gmc_vram_full_visible(&adev->gmc)),
		  "CPU update of VM recommended only for large BAR system\n");
		  "CPU update of VM recommended only for large BAR system\n");


	if (vm->use_cpu_for_update)
	if (vm->use_cpu_for_update) {
		/* Sync with last SDMA update/clear before switching to CPU */
		r = amdgpu_bo_sync_wait(vm->root.base.bo,
					AMDGPU_FENCE_OWNER_UNDEFINED, true);
		if (r)
			goto free_idr;

		vm->update_funcs = &amdgpu_vm_cpu_funcs;
		vm->update_funcs = &amdgpu_vm_cpu_funcs;
	else
	} else {
		vm->update_funcs = &amdgpu_vm_sdma_funcs;
		vm->update_funcs = &amdgpu_vm_sdma_funcs;
	}
	dma_fence_put(vm->last_update);
	dma_fence_put(vm->last_update);
	vm->last_update = NULL;
	vm->last_update = NULL;
	vm->is_compute_context = true;
	vm->is_compute_context = true;