aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux-4.19/linux-yocto-4.19.8/0979-dma-buf-add-dma_fence_get_stub.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux-4.19/linux-yocto-4.19.8/0979-dma-buf-add-dma_fence_get_stub.patch')
-rw-r--r--meta-amd-bsp/recipes-kernel/linux-4.19/linux-yocto-4.19.8/0979-dma-buf-add-dma_fence_get_stub.patch95
1 files changed, 95 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux-4.19/linux-yocto-4.19.8/0979-dma-buf-add-dma_fence_get_stub.patch b/meta-amd-bsp/recipes-kernel/linux-4.19/linux-yocto-4.19.8/0979-dma-buf-add-dma_fence_get_stub.patch
new file mode 100644
index 00000000..ccd19477
--- /dev/null
+++ b/meta-amd-bsp/recipes-kernel/linux-4.19/linux-yocto-4.19.8/0979-dma-buf-add-dma_fence_get_stub.patch
@@ -0,0 +1,95 @@
+From 53bb86bd5f7f4fabccd884ead6ef17dbbc422b09 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com>
+Date: Mon, 3 Dec 2018 13:36:14 +0100
+Subject: [PATCH 0979/2940] dma-buf: add dma_fence_get_stub
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Extract of useful code from the timeline work. This provides a function
+to return a stub or dummy fence which is always signaled.
+
+Signed-off-by: Christian König <christian.koenig@amd.com>
+Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
+Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
+Link: https://patchwork.freedesktop.org/patch/265248/
+---
+ drivers/dma-buf/dma-fence.c | 36 +++++++++++++++++++++++++++++++++++-
+ include/linux/dma-fence.h | 1 +
+ 2 files changed, 36 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
+index 1551ca7df394..136ec04d683f 100644
+--- a/drivers/dma-buf/dma-fence.c
++++ b/drivers/dma-buf/dma-fence.c
+@@ -30,13 +30,16 @@
+ EXPORT_TRACEPOINT_SYMBOL(dma_fence_emit);
+ EXPORT_TRACEPOINT_SYMBOL(dma_fence_enable_signal);
+
++static DEFINE_SPINLOCK(dma_fence_stub_lock);
++static struct dma_fence dma_fence_stub;
++
+ /*
+ * fence context counter: each execution context should have its own
+ * 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.
+ */
+-static atomic64_t dma_fence_context_counter = ATOMIC64_INIT(0);
++static atomic64_t dma_fence_context_counter = ATOMIC64_INIT(1);
+
+ /**
+ * DOC: DMA fences overview
+@@ -68,6 +71,37 @@ static atomic64_t dma_fence_context_counter = ATOMIC64_INIT(0);
+ * &dma_buf.resv pointer.
+ */
+
++static const char *dma_fence_stub_get_name(struct dma_fence *fence)
++{
++ return "stub";
++}
++
++static const struct dma_fence_ops dma_fence_stub_ops = {
++ .get_driver_name = dma_fence_stub_get_name,
++ .get_timeline_name = dma_fence_stub_get_name,
++};
++
++/**
++ * dma_fence_get_stub - return a signaled fence
++ *
++ * Return a stub fence which is already signaled.
++ */
++struct dma_fence *dma_fence_get_stub(void)
++{
++ spin_lock(&dma_fence_stub_lock);
++ if (!dma_fence_stub.ops) {
++ dma_fence_init(&dma_fence_stub,
++ &dma_fence_stub_ops,
++ &dma_fence_stub_lock,
++ 0, 0);
++ dma_fence_signal_locked(&dma_fence_stub);
++ }
++ spin_unlock(&dma_fence_stub_lock);
++
++ return dma_fence_get(&dma_fence_stub);
++}
++EXPORT_SYMBOL(dma_fence_get_stub);
++
+ /**
+ * dma_fence_context_alloc - allocate an array of fence contexts
+ * @num: amount of contexts to allocate
+diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
+index 02dba8cd033d..999e4b104410 100644
+--- a/include/linux/dma-fence.h
++++ b/include/linux/dma-fence.h
+@@ -541,6 +541,7 @@ static inline signed long dma_fence_wait(struct dma_fence *fence, bool intr)
+ return ret < 0 ? ret : 0;
+ }
+
++struct dma_fence *dma_fence_get_stub(void);
+ u64 dma_fence_context_alloc(unsigned num);
+
+ #define DMA_FENCE_TRACE(f, fmt, args...) \
+--
+2.17.1
+