Skip to contentSkip to conversation

drm/amdgpu: fix another missing fence reference in the CS code

PATCH In review Christian König 3 participants 7 messages Jan 5, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amdgpu: fix another missing fence reference in the CS code

drm_sched_job_add_dependency() consumes the references of the gang members. Only triggered by mesh shaders.

Fixes 1728baa7e4e6 ("drm/amdgpu: use scheduler dependencies for CS")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +4 -1
index 8516c814bc9b..47763ac0d14a 100644
@@ -1254,9 +1254,12 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
 			continue;
 
 		fence = &p->jobs[i]->base.s_fence->scheduled;
+		dma_fence_get(fence);
 		r = drm_sched_job_add_dependency(&leader->base, fence);
-		if (r)
+		if (r) {
+			dma_fence_put(fence);
 			goto error_cleanup;
+		}
 	}
 
 	if (p->gang_size > 1) {
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 drm/amdgpu: fix missing dma_fence_put in error path

When the fence can't be added we need to drop the reference.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c +3 -1
index bac7976975bd..dcd8c066bc1f 100644
@@ -391,8 +391,10 @@ int amdgpu_sync_push_to_job(struct amdgpu_sync *sync, struct amdgpu_job *job)
 
 		dma_fence_get(f);
 		r = drm_sched_job_add_dependency(&job->base, f);
-		if (r)
+		if (r) {
+			dma_fence_put(f);
 			return r;
+		}
 	}
 	return 0;
 }
Signature · 1 line
2.34.1
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/amdgpu: fix missing dma_fence_put in error path

Quoted 5 lines · Christian König

When the fence can't be added we need to drop the reference.

Series is:

Quoted 23 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c +3 -2
index bac7976975bd..dcd8c066bc1f 100644
@@ -391,8 +391,10 @@ int amdgpu_sync_push_to_job(struct amdgpu_sync *sync, struct amdgpu_job *job)
 
                dma_fence_get(f);
                r = drm_sched_job_add_dependency(&job->base, f);
-               if (r)
+               if (r) {
+                       dma_fence_put(f);
                        return r;
+               }
        }
        return 0;
 }
--

2.34.1

Reviewed-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] drm/amdgpu: fix missing dma_fence_put in error path

In reply to Christian König

Series is:

Regards,
Luben

Quoted 24 lines · Christian König

When the fence can't be added we need to drop the reference.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c +3 -1
index bac7976975bd..dcd8c066bc1f 100644
@@ -391,8 +391,10 @@ int amdgpu_sync_push_to_job(struct amdgpu_sync *sync, struct amdgpu_job *job)
 
 		dma_fence_get(f);
 		r = drm_sched_job_add_dependency(&job->base, f);
-		if (r)
+		if (r) {
+			dma_fence_put(f);
 			return r;
+		}
 	}
 	return 0;
 }
#4 lore raw

Re: [PATCH 2/2] drm/amdgpu: fix missing dma_fence_put in error path

In reply to Christian König
Quoted 5 lines · Christian König

When the fence can't be added we need to drop the reference.

please add:
Cc: [email protected] # 6.1.x
When you push this series.

Alex

Quoted 23 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c +3 -2
index bac7976975bd..dcd8c066bc1f 100644
@@ -391,8 +391,10 @@ int amdgpu_sync_push_to_job(struct amdgpu_sync *sync, struct amdgpu_job *job)
 
                dma_fence_get(f);
                r = drm_sched_job_add_dependency(&job->base, f);
-               if (r)
+               if (r) {
+                       dma_fence_put(f);
                        return r;
+               }
        }
        return 0;
 }
--

2.34.1

#5 lore raw

Re: [PATCH 2/2] drm/amdgpu: fix missing dma_fence_put in error path

Am 05.01.23 um 17:50 schrieb Alex Deucher:

Quoted 9 lines
Quoted 4 lines · Christian König

When the fence can't be added we need to drop the reference.

please add:
Cc: [email protected] # 6.1.x
When you push this series.

But none of this is in 6.1? That are pure 6.2 changes or am I missing something?

Christian.

Quoted 26 lines

Alex

Quoted 23 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c +3 -2
index bac7976975bd..dcd8c066bc1f 100644
@@ -391,8 +391,10 @@ int amdgpu_sync_push_to_job(struct amdgpu_sync *sync, struct amdgpu_job *job)
 
                 dma_fence_get(f);
                 r = drm_sched_job_add_dependency(&job->base, f);
-               if (r)
+               if (r) {
+                       dma_fence_put(f);
                         return r;
+               }
         }
         return 0;
  }
--

2.34.1

#6 lore raw

Re: [PATCH 2/2] drm/amdgpu: fix missing dma_fence_put in error path

Quoted 6 lines · Christian König

Am 05.01.23 um 17:50 schrieb Alex Deucher:

Quoted 4 lines
Quoted 2 lines · Christian König

When the fence can't be added we need to drop the reference.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

please add:
Cc: [email protected] # 6.1.x
When you push this series.

But none of this is in 6.1? That are pure 6.2 changes or am I missing something?

I thought patch 1 fixed an issue in the gang submit code which was in 6.1, or was that fixing an issue in a subsequent change?

Alex

Quoted 30 lines

Christian.

Quoted 26 lines

Alex

Quoted 23 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c +3 -2
index bac7976975bd..dcd8c066bc1f 100644
@@ -391,8 +391,10 @@ int amdgpu_sync_push_to_job(struct amdgpu_sync *sync, struct amdgpu_job *job)
 
                 dma_fence_get(f);
                 r = drm_sched_job_add_dependency(&job->base, f);
-               if (r)
+               if (r) {
+                       dma_fence_put(f);
                         return r;
+               }
         }
         return 0;
  }
--

2.34.1