Skip to content
/ linux Public

Commit 82a7ea3

Browse files
peppsacSasha Levin
authored andcommitted
drm/amdgpu: fix sync handling in amdgpu_dma_buf_move_notify
[ Upstream commit b18fc0a ] Invalidating a dmabuf will impact other users of the shared BO. In the scenario where process A moves the BO, it needs to inform process B about the move and process B will need to update its page table. The commit fixes a synchronisation bug caused by the use of the ticket: it made amdgpu_vm_handle_moved behave as if updating the page table immediately was correct but in this case it's not. An example is the following scenario, with 2 GPUs and glxgears running on GPU0 and Xorg running on GPU1, on a system where P2P PCI isn't supported: glxgears: export linear buffer from GPU0 and import using GPU1 submit frame rendering to GPU0 submit tiled->linear blit Xorg: copy of linear buffer The sequence of jobs would be: drm_sched_job_run # GPU0, frame rendering drm_sched_job_queue # GPU0, blit drm_sched_job_done # GPU0, frame rendering drm_sched_job_run # GPU0, blit move linear buffer for GPU1 access # amdgpu_dma_buf_move_notify -> update pt # GPU0 It this point the blit job on GPU0 is still running and would likely produce a page fault. Cc: stable@vger.kernel.org Fixes: a448cb0 ("drm/amdgpu: implement amdgpu_gem_prime_move_notify v2") Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 8f08df3 commit 82a7ea3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,15 @@ amdgpu_dma_buf_move_notify(struct dma_buf_attachment *attach)
418418
r = dma_resv_reserve_fences(resv, 2);
419419
if (!r)
420420
r = amdgpu_vm_clear_freed(adev, vm, NULL);
421+
422+
/* Don't pass 'ticket' to amdgpu_vm_handle_moved: we want the clear=true
423+
* path to be used otherwise we might update the PT of another process
424+
* while it's using the BO.
425+
* With clear=true, amdgpu_vm_bo_update will sync to command submission
426+
* from the same VM.
427+
*/
421428
if (!r)
422-
r = amdgpu_vm_handle_moved(adev, vm, ticket);
429+
r = amdgpu_vm_handle_moved(adev, vm, NULL);
423430

424431
if (r && r != -EBUSY)
425432
DRM_ERROR("Failed to invalidate VM page tables (%d))\n",

0 commit comments

Comments
 (0)