* [PATCH v2] drm/panthor: Fix the "done_fence is initialized" detection logic
@ 2026-03-09 12:43 Boris Brezillon
2026-03-09 12:50 ` Christian König
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Boris Brezillon @ 2026-03-09 12:43 UTC (permalink / raw)
To: Boris Brezillon, Steven Price, Liviu Dudau, Adrián Larumbe
Cc: dri-devel, kernel, Nicolas Frattaroli, Tvrtko Ursulin,
Philipp Stanner, Christian König
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 <nicolas.frattaroli@collabora.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: Christian König <christian.koenig@amd.com>
Reported-by: Steven Price <steven.price@arm.com>
Reported-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Fixes: 541c8f2468b9 ("dma-buf: detach fence ops on signal v3")
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
---
drivers/gpu/drm/panthor/panthor_sched.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
index bd703a2904a1..c15941ebe07a 100644
--- a/drivers/gpu/drm/panthor/panthor_sched.c
+++ b/drivers/gpu/drm/panthor/panthor_sched.c
@@ -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);
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2] drm/panthor: Fix the "done_fence is initialized" detection logic
2026-03-09 12:43 [PATCH v2] drm/panthor: Fix the "done_fence is initialized" detection logic Boris Brezillon
@ 2026-03-09 12:50 ` Christian König
2026-03-09 13:11 ` Nicolas Frattaroli
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Christian König @ 2026-03-09 12:50 UTC (permalink / raw)
To: Boris Brezillon, Steven Price, Liviu Dudau, Adrián Larumbe
Cc: dri-devel, kernel, Nicolas Frattaroli, Tvrtko Ursulin,
Philipp Stanner
On 3/9/26 13:43, Boris Brezillon wrote:
> 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 <nicolas.frattaroli@collabora.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
> Cc: Philipp Stanner <phasta@kernel.org>
> Cc: Christian König <christian.koenig@amd.com>
> Reported-by: Steven Price <steven.price@arm.com>
> Reported-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
> Fixes: 541c8f2468b9 ("dma-buf: detach fence ops on signal v3")
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/panthor/panthor_sched.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
> index bd703a2904a1..c15941ebe07a 100644
> --- a/drivers/gpu/drm/panthor/panthor_sched.c
> +++ b/drivers/gpu/drm/panthor/panthor_sched.c
> @@ -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);
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] drm/panthor: Fix the "done_fence is initialized" detection logic
2026-03-09 12:43 [PATCH v2] drm/panthor: Fix the "done_fence is initialized" detection logic Boris Brezillon
2026-03-09 12:50 ` Christian König
@ 2026-03-09 13:11 ` Nicolas Frattaroli
2026-03-09 15:11 ` Steven Price
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Nicolas Frattaroli @ 2026-03-09 13:11 UTC (permalink / raw)
To: Boris Brezillon, Steven Price, Liviu Dudau, Adrián Larumbe,
Boris Brezillon
Cc: dri-devel, kernel, Tvrtko Ursulin, Philipp Stanner,
Christian König
On Monday, 9 March 2026 13:43:18 Central European Standard Time Boris Brezillon wrote:
> 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 <nicolas.frattaroli@collabora.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
> Cc: Philipp Stanner <phasta@kernel.org>
> Cc: Christian König <christian.koenig@amd.com>
> Reported-by: Steven Price <steven.price@arm.com>
> Reported-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
> Fixes: 541c8f2468b9 ("dma-buf: detach fence ops on signal v3")
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> ---
> drivers/gpu/drm/panthor/panthor_sched.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
> index bd703a2904a1..c15941ebe07a 100644
> --- a/drivers/gpu/drm/panthor/panthor_sched.c
> +++ b/drivers/gpu/drm/panthor/panthor_sched.c
> @@ -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: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
This also fixes the refcount underflow for me. Thanks!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] drm/panthor: Fix the "done_fence is initialized" detection logic
2026-03-09 12:43 [PATCH v2] drm/panthor: Fix the "done_fence is initialized" detection logic Boris Brezillon
2026-03-09 12:50 ` Christian König
2026-03-09 13:11 ` Nicolas Frattaroli
@ 2026-03-09 15:11 ` Steven Price
2026-03-09 17:30 ` Liviu Dudau
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Steven Price @ 2026-03-09 15:11 UTC (permalink / raw)
To: Boris Brezillon, Liviu Dudau, Adrián Larumbe
Cc: dri-devel, kernel, Nicolas Frattaroli, Tvrtko Ursulin,
Philipp Stanner, Christian König
On 09/03/2026 12:43, Boris Brezillon wrote:
> 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 <nicolas.frattaroli@collabora.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
> Cc: Philipp Stanner <phasta@kernel.org>
> Cc: Christian König <christian.koenig@amd.com>
> Reported-by: Steven Price <steven.price@arm.com>
> Reported-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
> Fixes: 541c8f2468b9 ("dma-buf: detach fence ops on signal v3")
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Steven Price <steven.price@arm.com>
> ---
> drivers/gpu/drm/panthor/panthor_sched.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
> index bd703a2904a1..c15941ebe07a 100644
> --- a/drivers/gpu/drm/panthor/panthor_sched.c
> +++ b/drivers/gpu/drm/panthor/panthor_sched.c
> @@ -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);
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] drm/panthor: Fix the "done_fence is initialized" detection logic
2026-03-09 12:43 [PATCH v2] drm/panthor: Fix the "done_fence is initialized" detection logic Boris Brezillon
` (2 preceding siblings ...)
2026-03-09 15:11 ` Steven Price
@ 2026-03-09 17:30 ` Liviu Dudau
2026-03-10 2:23 ` Claude review: " Claude Code Review Bot
2026-03-10 2:23 ` Claude Code Review Bot
5 siblings, 0 replies; 7+ messages in thread
From: Liviu Dudau @ 2026-03-09 17:30 UTC (permalink / raw)
To: Boris Brezillon
Cc: Steven Price, Adrián Larumbe, dri-devel, kernel,
Nicolas Frattaroli, Tvrtko Ursulin, Philipp Stanner,
Christian König
On Mon, Mar 09, 2026 at 01:43:18PM +0100, Boris Brezillon wrote:
> 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 <nicolas.frattaroli@collabora.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
> Cc: Philipp Stanner <phasta@kernel.org>
> Cc: Christian König <christian.koenig@amd.com>
> Reported-by: Steven Price <steven.price@arm.com>
> Reported-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
> Fixes: 541c8f2468b9 ("dma-buf: detach fence ops on signal v3")
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
Best regards,
Liviu
> ---
> drivers/gpu/drm/panthor/panthor_sched.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
> index bd703a2904a1..c15941ebe07a 100644
> --- a/drivers/gpu/drm/panthor/panthor_sched.c
> +++ b/drivers/gpu/drm/panthor/panthor_sched.c
> @@ -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);
> --
> 2.53.0
>
--
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯
^ permalink raw reply [flat|nested] 7+ messages in thread
* Claude review: drm/panthor: Fix the "done_fence is initialized" detection logic
2026-03-09 12:43 [PATCH v2] drm/panthor: Fix the "done_fence is initialized" detection logic Boris Brezillon
` (4 preceding siblings ...)
2026-03-10 2:23 ` Claude review: " Claude Code Review Bot
@ 2026-03-10 2:23 ` Claude Code Review Bot
5 siblings, 0 replies; 7+ messages in thread
From: Claude Code Review Bot @ 2026-03-10 2:23 UTC (permalink / raw)
To: dri-devel-reviews
Overall Series Review
Subject: drm/panthor: Fix the "done_fence is initialized" detection logic
Author: Boris Brezillon <boris.brezillon@collabora.com>
Patches: 5
Reviewed: 2026-03-10T12:23:45.443064
---
This is a single-patch fix for the panthor GPU scheduler, addressing a regression introduced by commit `541c8f2468b9 ("dma-buf: detach fence ops on signal v3")`. That commit made `dma_fence::ops` get set to `NULL` upon fence signaling, which broke panthor's use of `->ops` as a proxy for "was this fence initialized." The fix correctly switches to the dedicated `dma_fence_was_initialized()` helper.
The patch is clean, correct, and well-motivated. **Looks good.**
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 7+ messages in thread
* Claude review: drm/panthor: Fix the "done_fence is initialized" detection logic
2026-03-09 12:43 [PATCH v2] drm/panthor: Fix the "done_fence is initialized" detection logic Boris Brezillon
` (3 preceding siblings ...)
2026-03-09 17:30 ` Liviu Dudau
@ 2026-03-10 2:23 ` Claude Code Review Bot
2026-03-10 2:23 ` Claude Code Review Bot
5 siblings, 0 replies; 7+ messages in thread
From: Claude Code Review Bot @ 2026-03-10 2:23 UTC (permalink / raw)
To: dri-devel-reviews
Patch Review
**Correctness**: The fix is correct. The old code:
```c
if (job->done_fence && job->done_fence->ops)
```
relied on `->ops` being non-NULL to distinguish an initialized (refcounted) fence from a merely allocated (kzalloc'd) one. After the upstream dma-buf change that clears `->ops` on signal, a signaled-but-initialized fence would incorrectly fall through to `dma_fence_free()` instead of `dma_fence_put()`, potentially causing a use-after-free or double-free.
The replacement:
```c
if (dma_fence_was_initialized(job->done_fence))
```
uses `dma_fence_was_initialized()` which checks `DMA_FENCE_FLAG_INITIALIZED_BIT` in `fence->flags` — a stable flag that survives signaling. It also handles the `fence == NULL` case internally (line 295 of `dma-fence.h`: `return fence && test_bit(...)`), so the NULL check that was previously part of the condition is preserved.
**Commit message**: Clear and well-structured. The `Fixes:` tag, `Reported-by:` tags, and v2 changelog are all present and correct.
**No issues found.** This is a straightforward, correct bug fix.
**Reviewed-by worthy**: Yes. The patch is minimal, well-targeted, and correctly uses the API designed for exactly this purpose.
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-03-10 2:23 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-09 12:43 [PATCH v2] drm/panthor: Fix the "done_fence is initialized" detection logic Boris Brezillon
2026-03-09 12:50 ` Christian König
2026-03-09 13:11 ` Nicolas Frattaroli
2026-03-09 15:11 ` Steven Price
2026-03-09 17:30 ` Liviu Dudau
2026-03-10 2:23 ` Claude review: " Claude Code Review Bot
2026-03-10 2:23 ` Claude Code Review Bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox