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

drm/amdgpu: 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-3-christian.koenig@amd.com

+13 -1
+13 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
··· 214 214 { 215 215 struct drm_gem_object *obj = attach->dmabuf->priv; 216 216 struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj); 217 + int r; 217 218 218 219 /* pin buffer into GTT */ 219 - return amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_GTT); 220 + r = amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_GTT); 221 + if (r) 222 + return r; 223 + 224 + if (bo->tbo.moving) { 225 + r = dma_fence_wait(bo->tbo.moving, true); 226 + if (r) { 227 + amdgpu_bo_unpin(bo); 228 + return r; 229 + } 230 + } 231 + return 0; 220 232 } 221 233 222 234 /**