drm/amdgpu: amdgpu_fence: remove ops->release()
Subsystems (3)
PATCH 1/1 drm/amdgpu: amdgpu_fence: remove ops->release()
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().
---
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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0 -29
@@ -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
Signature · 1 line
2.56.0
Quoted 7 lines · Philipp Stanner
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 akfree()on the fence - this functionality is already centrally implemented by thedma_fencebackend.
Quoted 7 lines
The
dma_fencebackend invokes akfree_rcu()on thedma_fence, which is fine since this is always the first member of a structamdgpu_fence. Thus, amdgpu's implementation is redundant.Remove
fence_ops->release().Signed-off-by Philipp Stanner <[email protected]>
I have exactly the same patch in my pipeline as well.
Quoted 55 lines
---
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(-)drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-29@@ -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
Alex Deucher
AppliedApplied. thanks!
Quoted 77 lines · Christian König
Quoted 7 lines · Philipp Stanner
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 akfree()on the fence - this functionality is already centrally implemented by thedma_fencebackend.Quoted 7 lines
The
dma_fencebackend invokes akfree_rcu()on thedma_fence, which is fine since this is always the first member of a structamdgpu_fence. Thus, amdgpu's implementation is redundant.Remove
fence_ops->release().Signed-off-by Philipp Stanner <[email protected]>I have exactly the same patch in my pipeline as well.
Reviewed-by Christian König <[email protected]>Quoted 55 lines
---
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(-)drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-29@@ -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