[Intel-gfx] [PATCH 1/3] dma-fence: Reserve 0 as a special NO_CONTEXT token

Chris Wilson chris at chris-wilson.co.uk
Sat Apr 8 16:26:01 UTC 2017


Reserve 0 for general use a token meaning that the fence doesn't belong
to an ordered timeline (fence context).

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Sumit Semwal <sumit.semwal at linaro.org>
Cc: Gustavo Padovan <gustavo at padovan.org>
Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
Cc: "Christian König" <christian.koenig at amd.com
Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
Cc: Alex Deucher <alexander.deucher at amd.com>
---
 drivers/dma-buf/dma-fence.c | 4 +++-
 include/linux/dma-fence.h   | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
index 0918d3f003d6..0646357ea350 100644
--- a/drivers/dma-buf/dma-fence.c
+++ b/drivers/dma-buf/dma-fence.c
@@ -36,8 +36,10 @@ EXPORT_TRACEPOINT_SYMBOL(dma_fence_enable_signal);
  * fence context, this allows checking if fences belong to the same
  * context or not. One device can have multiple separate contexts,
  * and they're used if some engine can run independently of another.
+ *
+ * 0 is excluded and treated as a special DMA_FENCE_NO_CONTEXT.
  */
-static atomic64_t dma_fence_context_counter = ATOMIC64_INIT(0);
+static atomic64_t dma_fence_context_counter = ATOMIC64_INIT(1);
 
 /**
  * dma_fence_context_alloc - allocate an array of fence contexts
diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
index 6048fa404e57..adfdc7fdd9c3 100644
--- a/include/linux/dma-fence.h
+++ b/include/linux/dma-fence.h
@@ -455,6 +455,8 @@ static inline signed long dma_fence_wait(struct dma_fence *fence, bool intr)
 	return ret < 0 ? ret : 0;
 }
 
+#define DMA_FENCE_NO_CONTEXT ((u64)0)
+
 u64 dma_fence_context_alloc(unsigned num);
 
 #define DMA_FENCE_TRACE(f, fmt, args...) \
-- 
2.11.0



More information about the Intel-gfx mailing list