diff mbox series

[08/16] drm/etnaviv: always wait for kernel fences

Message ID 20220406075132.3263-9-christian.koenig@amd.com (mailing list archive)
State New, archived
Headers show
Series [01/16] dma-buf/drivers: make reserving a shared slot mandatory v4 | expand

Commit Message

Christian König April 6, 2022, 7:51 a.m. UTC
Even for explicit synchronization we should wait for kernel fences.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 27 ++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

Comments

Daniel Vetter April 6, 2022, 12:46 p.m. UTC | #1
On Wed, Apr 06, 2022 at 09:51:24AM +0200, Christian König wrote:
> Even for explicit synchronization we should wait for kernel fences.

Yeah I don't think this patch makes much sense, because aside from etnaviv
there's also msm and lima which allow you to ignore all dma_resv fences
completely.

But it's also not an issue because these drivers don't move buffers, don't
have any other kernel fences and also don't do dynamic importing. I think
the real fix is replacing the write argument to
drm_sched_job_add_implicit_dependencies with dma_resv_usage and rolling
that out.

I'd just drop this for now, seems like a detour.
-Daniel

> 
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>  drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 27 ++++++++++++++++++--
>  1 file changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> index 98bb5c9239de..3fedd29732d5 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> @@ -171,6 +171,26 @@ static int submit_lock_objects(struct etnaviv_gem_submit *submit,
>  	return ret;
>  }
>  
> +/* TODO: This should be moved into the GPU scheduler if others need it */
> +static int submit_fence_kernel_sync(struct etnaviv_gem_submit *submit,
> +				    struct dma_resv *resv)
> +{
> +	struct dma_resv_iter cursor;
> +	struct dma_fence *fence;
> +	int ret;
> +
> +	dma_resv_for_each_fence(&cursor, resv, DMA_RESV_USAGE_KERNEL, fence) {
> +		/* Make sure to grab an additional ref on the added fence */
> +		dma_fence_get(fence);
> +		ret = drm_sched_job_add_dependency(&submit->sched_job, fence);
> +		if (ret) {
> +			dma_fence_put(fence);
> +			return ret;
> +		}
> +	}
> +	return 0;
> +}
> +
>  static int submit_fence_sync(struct etnaviv_gem_submit *submit)
>  {
>  	int i, ret = 0;
> @@ -183,8 +203,11 @@ static int submit_fence_sync(struct etnaviv_gem_submit *submit)
>  		if (ret)
>  			return ret;
>  
> -		if (submit->flags & ETNA_SUBMIT_NO_IMPLICIT)
> -			continue;
> +		if (submit->flags & ETNA_SUBMIT_NO_IMPLICIT) {
> +			ret = submit_fence_kernel_sync(submit, robj);
> +			if (ret)
> +				return ret;
> +		}
>  
>  		ret = drm_sched_job_add_implicit_dependencies(&submit->sched_job,
>  							      &bo->obj->base,
> -- 
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
index 98bb5c9239de..3fedd29732d5 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
@@ -171,6 +171,26 @@  static int submit_lock_objects(struct etnaviv_gem_submit *submit,
 	return ret;
 }
 
+/* TODO: This should be moved into the GPU scheduler if others need it */
+static int submit_fence_kernel_sync(struct etnaviv_gem_submit *submit,
+				    struct dma_resv *resv)
+{
+	struct dma_resv_iter cursor;
+	struct dma_fence *fence;
+	int ret;
+
+	dma_resv_for_each_fence(&cursor, resv, DMA_RESV_USAGE_KERNEL, fence) {
+		/* Make sure to grab an additional ref on the added fence */
+		dma_fence_get(fence);
+		ret = drm_sched_job_add_dependency(&submit->sched_job, fence);
+		if (ret) {
+			dma_fence_put(fence);
+			return ret;
+		}
+	}
+	return 0;
+}
+
 static int submit_fence_sync(struct etnaviv_gem_submit *submit)
 {
 	int i, ret = 0;
@@ -183,8 +203,11 @@  static int submit_fence_sync(struct etnaviv_gem_submit *submit)
 		if (ret)
 			return ret;
 
-		if (submit->flags & ETNA_SUBMIT_NO_IMPLICIT)
-			continue;
+		if (submit->flags & ETNA_SUBMIT_NO_IMPLICIT) {
+			ret = submit_fence_kernel_sync(submit, robj);
+			if (ret)
+				return ret;
+		}
 
 		ret = drm_sched_job_add_implicit_dependencies(&submit->sched_job,
 							      &bo->obj->base,