summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorArvind Yadav <Arvind.Yadav@amd.com>2025-04-25 17:06:50 +0300
committerAlex Deucher <alexander.deucher@amd.com>2025-05-05 20:29:44 +0300
commit575ec9b0c2f11f40535ea737ed5a64792780d1ef (patch)
treedbb0ad090f2b6b9c6069be938b42f7293dc3b66d /include/linux
parent71353c1a4f91a11c20eca51a48f550341e2e1556 (diff)
downloadlinux-575ec9b0c2f11f40535ea737ed5a64792780d1ef.tar.xz
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>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/dma-fence-unwrap.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/dma-fence-unwrap.h b/include/linux/dma-fence-unwrap.h
index 66b1e56fbb81..62df222fe0f1 100644
--- a/include/linux/dma-fence-unwrap.h
+++ b/include/linux/dma-fence-unwrap.h
@@ -52,6 +52,8 @@ struct dma_fence *__dma_fence_unwrap_merge(unsigned int num_fences,
struct dma_fence **fences,
struct dma_fence_unwrap *cursors);
+int dma_fence_dedup_array(struct dma_fence **array, int num_fences);
+
/**
* dma_fence_unwrap_merge - unwrap and merge fences
*