]> www.infradead.org Git - users/jedix/linux-maple.git/commit
dma-fence: Add helper to sort and deduplicate dma_fence arrays
authorArvind Yadav <Arvind.Yadav@amd.com>
Fri, 25 Apr 2025 14:06:50 +0000 (19:36 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 5 May 2025 17:29:44 +0000 (13:29 -0400)
commit575ec9b0c2f11f40535ea737ed5a64792780d1ef
treedbb0ad090f2b6b9c6069be938b42f7293dc3b66d
parent71353c1a4f91a11c20eca51a48f550341e2e1556
dma-fence: Add helper to sort and deduplicate dma_fence arrays

Export a new helper function `dma_fence_dedup_array()` that sorts
an array of dma_fence pointers by context, then deduplicates the array
by retaining only the most recent fence per context.

This utility is useful when merging or optimizing sets of fences where
redundant entries from the same context can be pruned. The operation is
performed in-place and releases references to dropped fences using
dma_fence_put().

v2: - Export this code from dma-fence-unwrap.c(by Christian).
v3: - To split this in a dma_buf patch and amd userq patch(by Sunil).
    - No need to add a new function just re-use existing(by Christian).
v4: - Export dma_fence_dedub_array and use it(by Christian).

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
Reviewed-by: Sunil Khatri <sunil.khatri@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Arvind Yadav <Arvind.Yadav@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/dma-buf/dma-fence-unwrap.c
include/linux/dma-fence-unwrap.h