summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2025-12-19 11:41:54 +0100
committerChristian König <christian.koenig@amd.com>2026-02-05 11:02:56 +0100
commit2bcbc706dfa02ae50118173a6f6d8a12e735480c (patch)
tree9fcaf1eaca2d7a94cb3001e085bb5e5d26358c01 /include
parent2bebc88d5e37ddcb5ea5039a39f39527662b27f0 (diff)
downloadlinux-2bcbc706dfa02ae50118173a6f6d8a12e735480c.tar.gz
linux-2bcbc706dfa02ae50118173a6f6d8a12e735480c.zip
dma-buf: add dma_fence_was_initialized function v2
Some driver use fence->ops to test if a fence was initialized or not. The problem is that this utilizes internal behavior of the dma_fence implementation. So better abstract that into a function. v2: use a flag instead of testing fence->ops, rename the function, move to the beginning of the patch set. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com> Link: https://lore.kernel.org/r/20260120105655.7134-2-christian.koenig@amd.com
Diffstat (limited to 'include')
-rw-r--r--include/linux/dma-fence.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
index d4c92fd35092..9c4d25289239 100644
--- a/include/linux/dma-fence.h
+++ b/include/linux/dma-fence.h
@@ -48,6 +48,7 @@ struct seq_file;
* atomic ops (bit_*), so taking the spinlock will not be needed most
* of the time.
*
+ * DMA_FENCE_FLAG_INITIALIZED_BIT - fence was initialized
* DMA_FENCE_FLAG_SIGNALED_BIT - fence is already signaled
* DMA_FENCE_FLAG_TIMESTAMP_BIT - timestamp recorded for fence signaling
* DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT - enable_signaling might have been called
@@ -98,6 +99,7 @@ struct dma_fence {
};
enum dma_fence_flag_bits {
+ DMA_FENCE_FLAG_INITIALIZED_BIT,
DMA_FENCE_FLAG_SEQNO64_BIT,
DMA_FENCE_FLAG_SIGNALED_BIT,
DMA_FENCE_FLAG_TIMESTAMP_BIT,
@@ -264,6 +266,19 @@ void dma_fence_free(struct dma_fence *fence);
void dma_fence_describe(struct dma_fence *fence, struct seq_file *seq);
/**
+ * dma_fence_was_initialized - test if fence was initialized
+ * @fence: fence to test
+ *
+ * Return: True if fence was ever initialized, false otherwise. Works correctly
+ * only when memory backing the fence structure is zero initialized on
+ * allocation.
+ */
+static inline bool dma_fence_was_initialized(struct dma_fence *fence)
+{
+ return fence && test_bit(DMA_FENCE_FLAG_INITIALIZED_BIT, &fence->flags);
+}
+
+/**
* dma_fence_put - decreases refcount of the fence
* @fence: fence to reduce refcount of
*/