All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] drm/nouveau: wait for moving fence after pinning v2
@ 2021-06-22 11:45 Christian König
  2021-06-22 11:45 ` [PATCH 2/3] drm/radeon: wait for moving fence after pinning Christian König
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Christian König @ 2021-06-22 11:45 UTC (permalink / raw)
  To: dri-devel, daniel.vetter

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

v2: grab the lock while waiting

Signed-off-by: Christian König <christian.koenig@amd.com>
References: https://lore.kernel.org/dri-devel/20210621151758.2347474-1-daniel.vetter@ffwll.ch/
CC: stable@kernel.org
---
 drivers/gpu/drm/nouveau/nouveau_prime.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c b/drivers/gpu/drm/nouveau/nouveau_prime.c
index 347488685f74..60019d0532fc 100644
--- a/drivers/gpu/drm/nouveau/nouveau_prime.c
+++ b/drivers/gpu/drm/nouveau/nouveau_prime.c
@@ -93,7 +93,22 @@ int nouveau_gem_prime_pin(struct drm_gem_object *obj)
 	if (ret)
 		return -EINVAL;
 
-	return 0;
+	ret = ttm_bo_reserve(&nvbo->bo, false, false, NULL);
+	if (ret)
+		goto error;
+
+	if (nvbo->bo.moving)
+		ret = dma_fence_wait(nvbo->bo.moving, true);
+
+	ttm_bo_unreserve(&nvbo->bo);
+	if (ret)
+		goto error;
+
+	return ret;
+
+error:
+	nouveau_bo_unpin(nvbo);
+	return ret;
 }
 
 void nouveau_gem_prime_unpin(struct drm_gem_object *obj)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] drm/radeon: wait for moving fence after pinning
  2021-06-22 11:45 [PATCH 1/3] drm/nouveau: wait for moving fence after pinning v2 Christian König
@ 2021-06-22 11:45 ` Christian König
  2021-06-22 11:45 ` [PATCH 3/3] drm/amdgpu: " Christian König
  2021-06-22 12:12 ` [PATCH 1/3] drm/nouveau: wait for moving fence after pinning v2 Daniel Vetter
  2 siblings, 0 replies; 4+ messages in thread
From: Christian König @ 2021-06-22 11:45 UTC (permalink / raw)
  To: dri-devel, daniel.vetter

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
---
 drivers/gpu/drm/radeon/radeon_prime.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_prime.c b/drivers/gpu/drm/radeon/radeon_prime.c
index 42a87948e28c..4a90807351e7 100644
--- a/drivers/gpu/drm/radeon/radeon_prime.c
+++ b/drivers/gpu/drm/radeon/radeon_prime.c
@@ -77,9 +77,19 @@ int radeon_gem_prime_pin(struct drm_gem_object *obj)
 
 	/* pin buffer into GTT */
 	ret = radeon_bo_pin(bo, RADEON_GEM_DOMAIN_GTT, NULL);
-	if (likely(ret == 0))
-		bo->prime_shared_count++;
-
+	if (unlikely(ret))
+		goto error;
+
+	if (bo->tbo.moving) {
+		ret = dma_fence_wait(bo->tbo.moving, false);
+		if (unlikely(ret)) {
+			radeon_bo_unpin(bo);
+			goto error;
+		}
+	}
+
+	bo->prime_shared_count++;
+error:
 	radeon_bo_unreserve(bo);
 	return ret;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] drm/amdgpu: wait for moving fence after pinning
  2021-06-22 11:45 [PATCH 1/3] drm/nouveau: wait for moving fence after pinning v2 Christian König
  2021-06-22 11:45 ` [PATCH 2/3] drm/radeon: wait for moving fence after pinning Christian König
@ 2021-06-22 11:45 ` Christian König
  2021-06-22 12:12 ` [PATCH 1/3] drm/nouveau: wait for moving fence after pinning v2 Daniel Vetter
  2 siblings, 0 replies; 4+ messages in thread
From: Christian König @ 2021-06-22 11:45 UTC (permalink / raw)
  To: dri-devel, daniel.vetter

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
---
 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) {
+		r = dma_fence_wait(bo->tbo.moving, true);
+		if (r) {
+			amdgpu_bo_unpin(bo);
+			return r;
+		}
+	}
+	return 0;
 }
 
 /**
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] drm/nouveau: wait for moving fence after pinning v2
  2021-06-22 11:45 [PATCH 1/3] drm/nouveau: wait for moving fence after pinning v2 Christian König
  2021-06-22 11:45 ` [PATCH 2/3] drm/radeon: wait for moving fence after pinning Christian König
  2021-06-22 11:45 ` [PATCH 3/3] drm/amdgpu: " Christian König
@ 2021-06-22 12:12 ` Daniel Vetter
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Vetter @ 2021-06-22 12:12 UTC (permalink / raw)
  To: Christian König; +Cc: dri-devel

On Tue, Jun 22, 2021 at 1:45 PM Christian König
<ckoenig.leichtzumerken@gmail.com> wrote:
>
> We actually need to wait for the moving fence after pinning
> the BO to make sure that the pin is completed.
>
> v2: grab the lock while waiting
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> References: https://lore.kernel.org/dri-devel/20210621151758.2347474-1-daniel.vetter@ffwll.ch/
> CC: stable@kernel.org

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/nouveau/nouveau_prime.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c b/drivers/gpu/drm/nouveau/nouveau_prime.c
> index 347488685f74..60019d0532fc 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_prime.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_prime.c
> @@ -93,7 +93,22 @@ int nouveau_gem_prime_pin(struct drm_gem_object *obj)
>         if (ret)
>                 return -EINVAL;
>
> -       return 0;
> +       ret = ttm_bo_reserve(&nvbo->bo, false, false, NULL);
> +       if (ret)
> +               goto error;
> +
> +       if (nvbo->bo.moving)
> +               ret = dma_fence_wait(nvbo->bo.moving, true);
> +
> +       ttm_bo_unreserve(&nvbo->bo);
> +       if (ret)
> +               goto error;
> +
> +       return ret;
> +
> +error:
> +       nouveau_bo_unpin(nvbo);
> +       return ret;
>  }
>
>  void nouveau_gem_prime_unpin(struct drm_gem_object *obj)
> --
> 2.25.1
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-22 12:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-22 11:45 [PATCH 1/3] drm/nouveau: wait for moving fence after pinning v2 Christian König
2021-06-22 11:45 ` [PATCH 2/3] drm/radeon: wait for moving fence after pinning Christian König
2021-06-22 11:45 ` [PATCH 3/3] drm/amdgpu: " Christian König
2021-06-22 12:12 ` [PATCH 1/3] drm/nouveau: wait for moving fence after pinning v2 Daniel Vetter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.