Message ID | 20210621130328.11070-3-christian.koenig@amd.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/3] drm/nouveau: wait for moving fence after pinning | expand |
On Mon, Jun 21, 2021 at 03:03:28PM +0200, Christian König wrote: > 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> > CC: stable@kernel.org > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c > index baa980a477d9..37ec59365080 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c > @@ -214,9 +214,21 @@ static int amdgpu_dma_buf_pin(struct dma_buf_attachment *attach) > { > struct drm_gem_object *obj = attach->dmabuf->priv; > struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj); > + int r; > > /* pin buffer into GTT */ > - return amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_GTT); > + r = amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_GTT); > + if (r) > + return r; > + > + if (bo->tbo.moving) { dma-buf.c guarantees we have the reservation here, so we're fine. Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> > + r = dma_fence_wait(bo->tbo.moving, true); > + if (r) { > + amdgpu_bo_unpin(bo); > + return r; > + } > + } > + return 0; > } > > /** > -- > 2.25.1 >
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c index baa980a477d9..37ec59365080 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c @@ -214,9 +214,21 @@ static int amdgpu_dma_buf_pin(struct dma_buf_attachment *attach) { struct drm_gem_object *obj = attach->dmabuf->priv; struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj); + int r; /* pin buffer into GTT */ - return amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_GTT); + r = amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_GTT); + if (r) + return r; + + if (bo->tbo.moving) { + r = dma_fence_wait(bo->tbo.moving, true); + if (r) { + amdgpu_bo_unpin(bo); + return r; + } + } + return 0; } /**
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> CC: stable@kernel.org --- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)