mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: amdgpu_fence: remove ops->release()
@ 2026-10-27 13:37 Philipp Stanner
  2026-10-27 13:40 ` Christian König
  0 siblings, 1 reply; 2+ messages in thread
From: Philipp Stanner @ 2026-10-27 13:37 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Sumit Semwal, Jesse Zhang, Timur Kristóf, Kexin Sun,
	Philipp Stanner, Srinivasan Shanmugam, Sakari Ailus
  Cc: amd-gfx, dri-devel, linux-kernel, linux-media

amdgpu's fence implements the deprecated fence_ops->release() callback
which prevents the driver from ever unloading robustly.

amdgpu's implementation merely uses a call_rcu() that performs a kfree()
on the fence - this functionality is already centrally implemented by
the dma_fence backend.

The dma_fence backend invokes a kfree_rcu() on the dma_fence, which is
fine since this is always the first member of a struct amdgpu_fence.
Thus, amdgpu's implementation is redundant.

Remove fence_ops->release().

Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
Just saw that this should be unnecessary? Don't have a setup for amdgpu
testing right now, so please take a close look, just compile-tested.

P.
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 29 -----------------------
 1 file changed, 29 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index 3043ad041bb4..3f8b2571d74a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -892,39 +892,10 @@ static bool amdgpu_fence_enable_signaling(struct dma_fence *f)
 	return true;
 }
 
-/**
- * amdgpu_fence_free - free up the fence memory
- *
- * @rcu: RCU callback head
- *
- * Free up the fence memory after the RCU grace period.
- */
-static void amdgpu_fence_free(struct rcu_head *rcu)
-{
-	struct dma_fence *f = container_of(rcu, struct dma_fence, rcu);
-
-	/* free fence_slab if it's separated fence*/
-	kfree(to_amdgpu_fence(f));
-}
-
-/**
- * amdgpu_fence_release - callback that fence can be freed
- *
- * @f: fence
- *
- * This function is called when the reference count becomes zero.
- * It just RCU schedules freeing up the fence.
- */
-static void amdgpu_fence_release(struct dma_fence *f)
-{
-	call_rcu(&f->rcu, amdgpu_fence_free);
-}
-
 static const struct dma_fence_ops amdgpu_fence_ops = {
 	.get_driver_name = amdgpu_fence_get_driver_name,
 	.get_timeline_name = amdgpu_fence_get_timeline_name,
 	.enable_signaling = amdgpu_fence_enable_signaling,
-	.release = amdgpu_fence_release,
 };
 
 /*

base-commit: 731ba09867520c047c7de53f92e384808e0b638e
-- 
2.56.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/amdgpu: amdgpu_fence: remove ops->release()
  2026-10-27 13:37 [PATCH] drm/amdgpu: amdgpu_fence: remove ops->release() Philipp Stanner
@ 2026-10-27 13:40 ` Christian König
  0 siblings, 0 replies; 2+ messages in thread
From: Christian König @ 2026-10-27 13:40 UTC (permalink / raw)
  To: Philipp Stanner, Alex Deucher, David Airlie, Simona Vetter,
	Sumit Semwal, Jesse Zhang, Timur Kristóf, Kexin Sun,
	Srinivasan Shanmugam, Sakari Ailus
  Cc: amd-gfx, dri-devel, linux-kernel, linux-media

On 10/27/26 14:37, Philipp Stanner wrote:
> amdgpu's fence implements the deprecated fence_ops->release() callback
> which prevents the driver from ever unloading robustly.
> 
> amdgpu's implementation merely uses a call_rcu() that performs a kfree()
> on the fence - this functionality is already centrally implemented by
> the dma_fence backend.
> 
> The dma_fence backend invokes a kfree_rcu() on the dma_fence, which is
> fine since this is always the first member of a struct amdgpu_fence.
> Thus, amdgpu's implementation is redundant.
> 
> Remove fence_ops->release().
> 
> Signed-off-by: Philipp Stanner <phasta@kernel.org>

I have exactly the same patch in my pipeline as well.

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
> Just saw that this should be unnecessary? Don't have a setup for amdgpu
> testing right now, so please take a close look, just compile-tested.
> 
> P.
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 29 -----------------------
>  1 file changed, 29 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> index 3043ad041bb4..3f8b2571d74a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> @@ -892,39 +892,10 @@ static bool amdgpu_fence_enable_signaling(struct dma_fence *f)
>  	return true;
>  }
>  
> -/**
> - * amdgpu_fence_free - free up the fence memory
> - *
> - * @rcu: RCU callback head
> - *
> - * Free up the fence memory after the RCU grace period.
> - */
> -static void amdgpu_fence_free(struct rcu_head *rcu)
> -{
> -	struct dma_fence *f = container_of(rcu, struct dma_fence, rcu);
> -
> -	/* free fence_slab if it's separated fence*/
> -	kfree(to_amdgpu_fence(f));
> -}
> -
> -/**
> - * amdgpu_fence_release - callback that fence can be freed
> - *
> - * @f: fence
> - *
> - * This function is called when the reference count becomes zero.
> - * It just RCU schedules freeing up the fence.
> - */
> -static void amdgpu_fence_release(struct dma_fence *f)
> -{
> -	call_rcu(&f->rcu, amdgpu_fence_free);
> -}
> -
>  static const struct dma_fence_ops amdgpu_fence_ops = {
>  	.get_driver_name = amdgpu_fence_get_driver_name,
>  	.get_timeline_name = amdgpu_fence_get_timeline_name,
>  	.enable_signaling = amdgpu_fence_enable_signaling,
> -	.release = amdgpu_fence_release,
>  };
>  
>  /*
> 
> base-commit: 731ba09867520c047c7de53f92e384808e0b638e


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-27 13:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-27 13:37 [PATCH] drm/amdgpu: amdgpu_fence: remove ops->release() Philipp Stanner
2026-10-27 13:40 ` Christian König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®