Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/radeon: wait for moving fence after pinning

We actually need to wait for the moving fence after pinning
the BO to make sure that the pin is completed.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
References: https://lore.kernel.org/dri-devel/20210621151758.2347474-1-daniel.vetter@ffwll.ch/
CC: stable@kernel.org
Link: https://patchwork.freedesktop.org/patch/msgid/20210622114506.106349-2-christian.koenig@amd.com

+12 -2
+12 -2
drivers/gpu/drm/radeon/radeon_prime.c
··· 77 77 78 78 /* pin buffer into GTT */ 79 79 ret = radeon_bo_pin(bo, RADEON_GEM_DOMAIN_GTT, NULL); 80 - if (likely(ret == 0)) 81 - bo->prime_shared_count++; 80 + if (unlikely(ret)) 81 + goto error; 82 82 83 + if (bo->tbo.moving) { 84 + ret = dma_fence_wait(bo->tbo.moving, false); 85 + if (unlikely(ret)) { 86 + radeon_bo_unpin(bo); 87 + goto error; 88 + } 89 + } 90 + 91 + bo->prime_shared_count++; 92 + error: 83 93 radeon_bo_unreserve(bo); 84 94 return ret; 85 95 }