From patchwork Fri Aug 1 06:23:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 4660871 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9EC00C0338 for ; Fri, 1 Aug 2014 06:34:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C84A320204 for ; Fri, 1 Aug 2014 06:34:26 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8F1F120200 for ; Fri, 1 Aug 2014 06:34:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E4BD06E70B; Thu, 31 Jul 2014 23:34:23 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org X-Greylist: delayed 627 seconds by postgrey-1.34 at gabe; Thu, 31 Jul 2014 23:34:23 PDT Received: from mblankhorst.nl (mblankhorst.nl [141.105.120.124]) by gabe.freedesktop.org (Postfix) with ESMTP id 3C7236E70B for ; Thu, 31 Jul 2014 23:34:22 -0700 (PDT) Received: from ubuntu-mbp.local (5ED48CED.cm-7-5c.dynamic.ziggo.nl [94.212.140.237]) (using TLSv1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: mlankhorst) by mblankhorst.nl (Postfix) with ESMTPSA id C853E18C0B1; Fri, 1 Aug 2014 08:21:39 +0200 (CEST) Message-ID: <53DB3275.6010102@canonical.com> Date: Fri, 01 Aug 2014 08:23:49 +0200 From: Maarten Lankhorst User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Jesse Barnes , intel-gfx@lists.freedesktop.org References: <1406833088-25801-1-git-send-email-jbarnes@virtuousgeek.org> <1406833088-25801-2-git-send-email-jbarnes@virtuousgeek.org> In-Reply-To: <1406833088-25801-2-git-send-email-jbarnes@virtuousgeek.org> Subject: Re: [Intel-gfx] [PATCH] drm/i915: Android sync points for i915 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hey, On 31-07-14 20:58, Jesse Barnes wrote: > Expose an ioctl to create Android fences based on the Android sync point > infrastructure (which in turn is based on DMA-buf fences). Just a > sketch at this point, no testing has been done. > > There are a couple of goals here: > 1) allow applications and libraries to create fences without an > associated buffer > 2) re-use a common API so userspace doesn't have to impedance mismatch > between different driver implementations too much > 3) allow applications and libraries to use explicit synchronization if > they choose by exposing fences directly > Do you really need to use android timelines here? I think you should be able to use fence directly, and export android userspace fences anyway, you could easily wrap them. ~Maarten Untested uncompiled patch for that below, looking from the documentation I may have caused a memory leak by taking a reference on the sync_pt.. diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index ba0d69e..201b088 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -179,7 +179,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; @@ -190,16 +190,21 @@ struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt) fence->num_fences = 1; atomic_set(&fence->status, 1); - fence_get(&pt->base); - fence->cbs[0].sync_pt = &pt->base; + fence->cbs[0].sync_pt = fence_get(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) diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index bcdd119..6d1682a 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -242,8 +242,9 @@ void sync_pt_free(struct sync_pt *pt); * @pt: sync_pt to add to the fence * * Creates a fence containg @pt. Once this is called, the fence takes - * ownership of @pt. + * a reference on @pt. */ +struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt); struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt); /*