staging/android/sync: add sync_fence_create_dma
authorMaarten Lankhorst <maarten.lankhorst@canonical.com>
Fri, 11 Dec 2015 13:11:50 +0000 (13:11 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 21 Dec 2015 21:37:53 +0000 (13:37 -0800)
This allows users of dma fences to create a android fence.

v2: Added kerneldoc. (Tvrtko Ursulin).

v4: Updated comments from review feedback my Maarten.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: devel@driverdev.osuosl.org
Cc: Riley Andrews <riandrews@android.com>
Cc: Arve Hjønnevåg <arve@android.com>
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Tested-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/android/sync.c
drivers/staging/android/sync.h

index e0c1acb2ba69c49b674ca9ec1827842a75e9b7f8..78c62dfb397876e40dbed79e0441cabf4ab3bdbc 100644 (file)
@@ -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)
+struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt)
 {
        struct sync_fence *fence;
 
@@ -199,16 +199,21 @@ 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;
 }
+EXPORT_SYMBOL(sync_fence_create_dma);
+
+struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt)
+{
+       return sync_fence_create_dma(name, &pt->base);
+}
 EXPORT_SYMBOL(sync_fence_create);
 
 struct sync_fence *sync_fence_fdget(int fd)
index 61f8a3aede96ead8641b00c74aa8bbd38a1f00a7..afa0752275a722ed69f6161f3e79ed1b21082ad0 100644 (file)
@@ -254,6 +254,16 @@ 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 dma-fence
+ * @name:      name of fence to create
+ * @pt:        dma-fence to add to the fence
+ *
+ * Creates a fence containg @pt.  Once this is called, the fence takes
+ * ownership of @pt.
+ */
+struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt);
+
 /*
  * API for sync_fence consumers
  */