diff mbox series

[6/6] drm/radeon: use dma_resv_wait_timeout() instead of manually waiting

Message ID 20211028132630.2330-6-christian.koenig@amd.com (mailing list archive)
State New, archived
Headers show
Series [1/6] dma-buf: move dma_resv_prune_unlocked into dma_resv.c | expand

Commit Message

Christian König Oct. 28, 2021, 1:26 p.m. UTC
Don't touch the exclusive fence manually here, but rather use the
general dma_resv function. We did that for better hw reset handling but
this doesn't necessary work correctly.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/radeon/radeon_uvd.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Comments

Christian König Nov. 3, 2021, 7:55 a.m. UTC | #1
Ping, Alex do you have a moment for that one here?

Am 28.10.21 um 15:26 schrieb Christian König:
> Don't touch the exclusive fence manually here, but rather use the
> general dma_resv function. We did that for better hw reset handling but
> this doesn't necessary work correctly.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>   drivers/gpu/drm/radeon/radeon_uvd.c | 13 +++++--------
>   1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c
> index 2ea86919d953..377f9cdb5b53 100644
> --- a/drivers/gpu/drm/radeon/radeon_uvd.c
> +++ b/drivers/gpu/drm/radeon/radeon_uvd.c
> @@ -469,7 +469,6 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
>   {
>   	int32_t *msg, msg_type, handle;
>   	unsigned img_size = 0;
> -	struct dma_fence *f;
>   	void *ptr;
>   
>   	int i, r;
> @@ -479,13 +478,11 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
>   		return -EINVAL;
>   	}
>   
> -	f = dma_resv_excl_fence(bo->tbo.base.resv);
> -	if (f) {
> -		r = radeon_fence_wait((struct radeon_fence *)f, false);
> -		if (r) {
> -			DRM_ERROR("Failed waiting for UVD message (%d)!\n", r);
> -			return r;
> -		}
> +	r = dma_resv_wait_timeout(bo->tbo.base.resv, false, false,
> +				  MAX_SCHEDULE_TIMEOUT);
> +	if (r <= 0) {
> +		DRM_ERROR("Failed waiting for UVD message (%d)!\n", r);
> +		return r ? r : -ETIME;
>   	}
>   
>   	r = radeon_bo_kmap(bo, &ptr);
Das, Nirmoy Nov. 3, 2021, 4:36 p.m. UTC | #2
Acked-by: Nirmoy Das <nirmoy.das@amd.com>

On 10/28/2021 3:26 PM, Christian König wrote:
> Don't touch the exclusive fence manually here, but rather use the
> general dma_resv function. We did that for better hw reset handling but
> this doesn't necessary work correctly.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>   drivers/gpu/drm/radeon/radeon_uvd.c | 13 +++++--------
>   1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c
> index 2ea86919d953..377f9cdb5b53 100644
> --- a/drivers/gpu/drm/radeon/radeon_uvd.c
> +++ b/drivers/gpu/drm/radeon/radeon_uvd.c
> @@ -469,7 +469,6 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
>   {
>   	int32_t *msg, msg_type, handle;
>   	unsigned img_size = 0;
> -	struct dma_fence *f;
>   	void *ptr;
>   
>   	int i, r;
> @@ -479,13 +478,11 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
>   		return -EINVAL;
>   	}
>   
> -	f = dma_resv_excl_fence(bo->tbo.base.resv);
> -	if (f) {
> -		r = radeon_fence_wait((struct radeon_fence *)f, false);
> -		if (r) {
> -			DRM_ERROR("Failed waiting for UVD message (%d)!\n", r);
> -			return r;
> -		}
> +	r = dma_resv_wait_timeout(bo->tbo.base.resv, false, false,
> +				  MAX_SCHEDULE_TIMEOUT);
> +	if (r <= 0) {
> +		DRM_ERROR("Failed waiting for UVD message (%d)!\n", r);
> +		return r ? r : -ETIME;
>   	}
>   
>   	r = radeon_bo_kmap(bo, &ptr);
diff mbox series

Patch

diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c
index 2ea86919d953..377f9cdb5b53 100644
--- a/drivers/gpu/drm/radeon/radeon_uvd.c
+++ b/drivers/gpu/drm/radeon/radeon_uvd.c
@@ -469,7 +469,6 @@  static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
 {
 	int32_t *msg, msg_type, handle;
 	unsigned img_size = 0;
-	struct dma_fence *f;
 	void *ptr;
 
 	int i, r;
@@ -479,13 +478,11 @@  static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
 		return -EINVAL;
 	}
 
-	f = dma_resv_excl_fence(bo->tbo.base.resv);
-	if (f) {
-		r = radeon_fence_wait((struct radeon_fence *)f, false);
-		if (r) {
-			DRM_ERROR("Failed waiting for UVD message (%d)!\n", r);
-			return r;
-		}
+	r = dma_resv_wait_timeout(bo->tbo.base.resv, false, false,
+				  MAX_SCHEDULE_TIMEOUT);
+	if (r <= 0) {
+		DRM_ERROR("Failed waiting for UVD message (%d)!\n", r);
+		return r ? r : -ETIME;
 	}
 
 	r = radeon_bo_kmap(bo, &ptr);