From: Maarten Lankhorst <maarten.lankhorst@canonical.com>
To: Sumit Semwal <sumit.semwal@linaro.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linaro-mm-sig@lists.linaro.org" <linaro-mm-sig@lists.linaro.org>,
LKML <linux-kernel@vger.kernel.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
Colin Cross <ccross@google.com>,
John Stultz <john.stultz@linaro.org>,
devel@driverdev.osuosl.org,
Jesse Barnes <jbarnes@virtuousgeek.org>
Subject: [PATCH 2/2] android: add sync_fence_create_dma
Date: Thu, 14 Aug 2014 11:54:52 +0200 [thread overview]
Message-ID: <53EC876C.9050705@canonical.com> (raw)
In-Reply-To: <53EC8722.4070407@canonical.com>
This allows users of dma fences to create a android fence.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
---
drivers/staging/android/sync.c | 24 ++++++++++++++++++++----
drivers/staging/android/sync.h | 11 +++++++++++
2 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index 69139ce7420d..c9331250ac26 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -188,7 +188,7 @@ static void fence_check_cb_func(struct fence *f, struct fence_cb *cb)
}
/* TODO: implement a create which takes more that one sync_pt */
-struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt)
+static struct sync_fence *sync_fence_create_noref(const char *name, struct fence *pt)
{
struct sync_fence *fence;
@@ -199,16 +199,32 @@ struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt)
fence->num_fences = 1;
atomic_set(&fence->status, 1);
- fence->cbs[0].sync_pt = &pt->base;
+ fence->cbs[0].sync_pt = pt;
fence->cbs[0].fence = fence;
- if (fence_add_callback(&pt->base, &fence->cbs[0].cb,
- fence_check_cb_func))
+ if (fence_add_callback(pt, &fence->cbs[0].cb, fence_check_cb_func))
atomic_dec(&fence->status);
sync_fence_debug_add(fence);
return fence;
}
+
+struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt)
+{
+ struct sync_fence *fence;
+
+ fence = sync_fence_create_noref(name, fence_get(pt));
+ if (!fence)
+ fence_put(pt);
+
+ return fence;
+}
+EXPORT_SYMBOL(sync_fence_create_dma);
+
+struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt)
+{
+ return sync_fence_create_noref(name, &pt->base);
+}
EXPORT_SYMBOL(sync_fence_create);
struct sync_fence *sync_fence_fdget(int fd)
diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h
index 66b0f431f63e..7b3bf560790c 100644
--- a/drivers/staging/android/sync.h
+++ b/drivers/staging/android/sync.h
@@ -254,6 +254,17 @@ void sync_pt_free(struct sync_pt *pt);
*/
struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt);
+/**
+ * sync_fence_create_dma() - creates a sync fence from a dma fence
+ * @name: name of fence to create
+ * @pt: dma fence to add to the sync fence
+ *
+ * Creates a fence containg @pt. Once this is called, the fence takes
+ * a reference on @pt, unlike sync_fence_create which doesn't add one.
+ */
+struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt);
+
+
/*
* API for sync_fence consumers
*/
--
2.0.4
next prev parent reply other threads:[~2014-08-14 9:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-14 9:53 [PATCH 1/2] android: fix reference leak in sync_fence_create Maarten Lankhorst
2014-08-14 9:54 ` Maarten Lankhorst [this message]
2014-08-14 20:09 ` [PATCH 2/2] android: add sync_fence_create_dma Jesse Barnes
2014-08-15 6:46 ` Greg Kroah-Hartman
2014-08-15 16:23 ` Jesse Barnes
2014-08-28 6:54 ` Maarten Lankhorst
2014-08-28 11:57 ` Dan Carpenter
2014-09-01 12:33 ` Maarten Lankhorst
2014-09-01 12:45 ` Dan Carpenter
2014-08-18 12:57 ` [PATCH 1/2] android: fix reference leak in sync_fence_create Dan Carpenter
2014-08-18 13:06 ` Maarten Lankhorst
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53EC876C.9050705@canonical.com \
--to=maarten.lankhorst@canonical.com \
--cc=ccross@google.com \
--cc=daniel.vetter@ffwll.ch \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=jbarnes@virtuousgeek.org \
--cc=john.stultz@linaro.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sumit.semwal@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).