Am 05.03.22 um 13:17 schrieb wangshumin:
The function dma_fence_free() works fine because
struct dma_fence is the first member of sync object.
Use `kfree` make it more reasonable.
Well, NAK. You haven't understood what this is good for.
All dma_fence implementations must free their memory RCU safe. In other
words they must use kfree_rcu() using the rcu member in the base
dma_fence object.
dma_fence_free() is now a wrapper around that to better abstract the
functionality.
Your patch would break that and cause hard to debug memory corruptions.
We could potentially rename the function to make the functionality more
clear, but this here is just bluntly nonsense.
Regards,
Christian.
Signed-off-by: wangshumin <pdsrazor@xxxxxxxxx>
---
drivers/dma-buf/dma-fence-array.c | 2 +-
drivers/dma-buf/dma-fence-chain.c | 2 +-
drivers/dma-buf/sw_sync.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
index cb1bacb5a42b..fc52d837e579 100644
--- a/drivers/dma-buf/dma-fence-array.c
+++ b/drivers/dma-buf/dma-fence-array.c
@@ -120,7 +120,7 @@ static void dma_fence_array_release(struct dma_fence *fence)
dma_fence_put(array->fences[i]);
kfree(array->fences);
- dma_fence_free(fence);
+ kfree(array);
}
const struct dma_fence_ops dma_fence_array_ops = {
diff --git a/drivers/dma-buf/dma-fence-chain.c b/drivers/dma-buf/dma-fence-chain.c
index 06f8ef97c6e8..b29e1f22f08e 100644
--- a/drivers/dma-buf/dma-fence-chain.c
+++ b/drivers/dma-buf/dma-fence-chain.c
@@ -203,7 +203,7 @@ static void dma_fence_chain_release(struct dma_fence *fence)
dma_fence_put(prev);
dma_fence_put(chain->fence);
- dma_fence_free(fence);
+ kfree(chain);
}
const struct dma_fence_ops dma_fence_chain_ops = {
diff --git a/drivers/dma-buf/sw_sync.c b/drivers/dma-buf/sw_sync.c
index 348b3a9170fa..80432eeb58c3 100644
--- a/drivers/dma-buf/sw_sync.c
+++ b/drivers/dma-buf/sw_sync.c
@@ -142,7 +142,7 @@ static void timeline_fence_release(struct dma_fence *fence)
spin_unlock_irqrestore(fence->lock, flags);
sync_timeline_put(parent);
- dma_fence_free(fence);
+ kfree(pt);
}
static bool timeline_fence_signaled(struct dma_fence *fence)