Skip to contentSkip to conversation

drm/panthor: Fix the "done_fence is initialized" detection logic

PATCH Applied Boris Brezillon 5 participants 6 messages Mar 9 – Mar 11

Subsystems (3)
lore
Share & tools
lore

Boris Brezillon

author maintainer
#0 lore raw

PATCH v2 1/1 drm/panthor: Fix the "done_fence is initialized" detection logic

After commit 541c8f2468b9 ("dma-buf: detach fence ops on signal v3"), dma_fence::ops == NULL can't be used to check if the fence is initialized. Use dma_fence_was_initialized() instead.

v2:
- Use dma_fence_was_initialized() instead of open-coding it

Cc Nicolas Frattaroli <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Philipp Stanner <[email protected]>
Cc Christian König <[email protected]>
Fixes 541c8f2468b9 ("dma-buf: detach fence ops on signal v3")
---
 drivers/gpu/drm/panthor/panthor_sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/panthor/panthor_sched.c +1 -1
index bd703a2904a1..c15941ebe07a 100644
@@ -3915,7 +3915,7 @@ static void job_release(struct kref *ref)
 	if (job->base.s_fence)
 		drm_sched_job_cleanup(&job->base);
 
-	if (job->done_fence && job->done_fence->ops)
+	if (dma_fence_was_initialized(job->done_fence))
 		dma_fence_put(job->done_fence);
 	else
 		dma_fence_free(job->done_fence);
Signature · 1 line
2.53.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Boris Brezillon

After commit 541c8f2468b9 ("dma-buf: detach fence ops on signal v3"), dma_fence::ops == NULL can't be used to check if the fence is initialized. Use dma_fence_was_initialized() instead.

v2:
- Use dma_fence_was_initialized() instead of open-coding it

Quoted 8 lines
Cc Nicolas Frattaroli <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Philipp Stanner <[email protected]>
Cc Christian König <[email protected]>
Fixes 541c8f2468b9 ("dma-buf: detach fence ops on signal v3")
Quoted 17 lines
---
 drivers/gpu/drm/panthor/panthor_sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/panthor/panthor_sched.c +1 -1
index bd703a2904a1..c15941ebe07a 100644
@@ -3915,7 +3915,7 @@ static void job_release(struct kref *ref)
 	if (job->base.s_fence)
 		drm_sched_job_cleanup(&job->base);
 
-	if (job->done_fence && job->done_fence->ops)
+	if (dma_fence_was_initialized(job->done_fence))
 		dma_fence_put(job->done_fence);
 	else
 		dma_fence_free(job->done_fence);
Tested-by on v2 1/1
#2 lore raw
In reply to Boris Brezillon
Quoted 25 lines · On Monday, 9 March 2026 13:43:18 Central European Standard Time Boris…

After commit 541c8f2468b9 ("dma-buf: detach fence ops on signal v3"), dma_fence::ops == NULL can't be used to check if the fence is initialized. Use dma_fence_was_initialized() instead.

v2:
- Use dma_fence_was_initialized() instead of open-coding it

Cc Nicolas Frattaroli <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Philipp Stanner <[email protected]>
Cc Christian König <[email protected]>
Fixes 541c8f2468b9 ("dma-buf: detach fence ops on signal v3")
---
 drivers/gpu/drm/panthor/panthor_sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/panthor/panthor_sched.c +0 -0
index bd703a2904a1..c15941ebe07a 100644

drivers/gpu/drm/panthor/panthor_sched.c static void job_release(struct kref *ref) · line 3921

Quoted 8 lines
drivers/gpu/drm/panthor/panthor_sched.c +1 -1
@@ -3915,7 +3915,7 @@ static void job_release(struct kref *ref)
 	if (job->base.s_fence)
 		drm_sched_job_cleanup(&job->base);
 
-	if (job->done_fence && job->done_fence->ops)
+	if (dma_fence_was_initialized(job->done_fence))
 		dma_fence_put(job->done_fence);
 	else
 		dma_fence_free(job->done_fence);

This also fixes the refcount underflow for me. Thanks!

maintainer Reviewed-by on v2 1/1
#3 lore raw
In reply to Boris Brezillon
Quoted 7 lines · Boris Brezillon

After commit 541c8f2468b9 ("dma-buf: detach fence ops on signal v3"), dma_fence::ops == NULL can't be used to check if the fence is initialized. Use dma_fence_was_initialized() instead.

v2:
- Use dma_fence_was_initialized() instead of open-coding it

Quoted 8 lines
Cc Nicolas Frattaroli <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Philipp Stanner <[email protected]>
Cc Christian König <[email protected]>
Fixes 541c8f2468b9 ("dma-buf: detach fence ops on signal v3")
Quoted 17 lines
---
 drivers/gpu/drm/panthor/panthor_sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/panthor/panthor_sched.c +1 -1
index bd703a2904a1..c15941ebe07a 100644
@@ -3915,7 +3915,7 @@ static void job_release(struct kref *ref)
 	if (job->base.s_fence)
 		drm_sched_job_cleanup(&job->base);
 
-	if (job->done_fence && job->done_fence->ops)
+	if (dma_fence_was_initialized(job->done_fence))
 		dma_fence_put(job->done_fence);
 	else
 		dma_fence_free(job->done_fence);
maintainer Reviewed-by on v2 1/1
#4 lore raw
In reply to Boris Brezillon
Quoted 7 lines · Boris Brezillon

After commit 541c8f2468b9 ("dma-buf: detach fence ops on signal v3"), dma_fence::ops == NULL can't be used to check if the fence is initialized. Use dma_fence_was_initialized() instead.

v2:
- Use dma_fence_was_initialized() instead of open-coding it

Quoted 8 lines
Cc Nicolas Frattaroli <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Philipp Stanner <[email protected]>
Cc Christian König <[email protected]>
Fixes 541c8f2468b9 ("dma-buf: detach fence ops on signal v3")

Best regards,
Liviu

Quoted 20 lines
---
 drivers/gpu/drm/panthor/panthor_sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/panthor/panthor_sched.c +1 -1
index bd703a2904a1..c15941ebe07a 100644
@@ -3915,7 +3915,7 @@ static void job_release(struct kref *ref)
 	if (job->base.s_fence)
 		drm_sched_job_cleanup(&job->base);
 
-	if (job->done_fence && job->done_fence->ops)
+	if (dma_fence_was_initialized(job->done_fence))
 		dma_fence_put(job->done_fence);
 	else
 		dma_fence_free(job->done_fence);
Signature · 1 line
2.53.0
Signature · 8 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
maintainer Applied
#5 lore raw
In reply to Boris Brezillon
Quoted 7 lines · Boris Brezillon

After commit 541c8f2468b9 ("dma-buf: detach fence ops on signal v3"), dma_fence::ops == NULL can't be used to check if the fence is initialized. Use dma_fence_was_initialized() instead.

v2:
- Use dma_fence_was_initialized() instead of open-coding it

Quoted 8 lines
Cc Nicolas Frattaroli <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Philipp Stanner <[email protected]>
Cc Christian König <[email protected]>
Fixes 541c8f2468b9 ("dma-buf: detach fence ops on signal v3")

Applied to drm-misc-next.

Thanks,
Steve

Quoted 17 lines
---
 drivers/gpu/drm/panthor/panthor_sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/panthor/panthor_sched.c +1 -1
index bd703a2904a1..c15941ebe07a 100644
@@ -3915,7 +3915,7 @@ static void job_release(struct kref *ref)
 	if (job->base.s_fence)
 		drm_sched_job_cleanup(&job->base);
 
-	if (job->done_fence && job->done_fence->ops)
+	if (dma_fence_was_initialized(job->done_fence))
 		dma_fence_put(job->done_fence);
 	else
 		dma_fence_free(job->done_fence);