Skip to contentSkip to conversation

drm/amdgpu: amdgpu_fence: remove ops->release()

PATCH Applied Philipp Stanner 3 participants 3 messages Oct 27 – Oct 29

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

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
index 3043ad041bb4..3f8b2571d74a 100644
@@ -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
maintainer Reviewed-by on v1 1/1
#1 lore raw
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 a kfree() on the fence - this functionality is already centrally implemented by the dma_fence backend.

Quoted 7 lines

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().

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
index 3043ad041bb4..3f8b2571d74a 100644
@@ -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

Applied
#2 lore raw

Applied. 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 a kfree() on the fence - this functionality is already centrally implemented by the dma_fence backend.

Quoted 7 lines

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().

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
index 3043ad041bb4..3f8b2571d74a 100644
@@ -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