From patchwork Thu Jun 23 15:29:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9195469 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2D7F86075A for ; Thu, 23 Jun 2016 15:30:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E2D42842E for ; Thu, 23 Jun 2016 15:30:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12BFD28464; Thu, 23 Jun 2016 15:30:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2A722842E for ; Thu, 23 Jun 2016 15:30:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 917E36E978; Thu, 23 Jun 2016 15:30:27 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yw0-f194.google.com (mail-yw0-f194.google.com [209.85.161.194]) by gabe.freedesktop.org (Postfix) with ESMTPS id D1E8A6E3BC for ; Thu, 23 Jun 2016 15:30:19 +0000 (UTC) Received: by mail-yw0-f194.google.com with SMTP id l125so11304642ywb.1 for ; Thu, 23 Jun 2016 08:30:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0WfKWfTWBhAjSWr6PjKe7wrqmAHv/VwOLZlV/oefXXk=; b=hRQ8FhO4CTc0/Abho9mPdVvJ9Lf2eGj07Upd1AaBKEj7B9VYjB18HZaPdsO3RvV2nc B85OjDdZwJUBJZz6s++kc0jROkarGgt3Lt41GW7f3BicciMmxqsdUF6XaFxYpHTE7ITS gLtQBFkJJIWsXgc7yZPuwdHdkK068HMK+oaANFMPtEJy2lQhyLGn7hmEee6Mx0lcAGPJ WNnuLvL2LETUBsuIANHAGd9P7bg/V7p78Pb4BZyYjU2wEVYlwNimeShUjuZLFybcRgnY idJK4B2KhHqJHO8yolzJf4Ql93IjtoWrzBeqHROdkC6Fx9D85gO9X9QjlQFIPhUfBxf9 IavQ== X-Gm-Message-State: ALyK8tK22sm/7hmv4WambtpKuI4cJUKofnL77WiYVQuTtnG1FK2qxrsaLpUxtDy6Evyvug== X-Received: by 10.13.200.198 with SMTP id k189mr20156471ywd.61.1466695818652; Thu, 23 Jun 2016 08:30:18 -0700 (PDT) Received: from jade.localdomain ([189.61.225.79]) by smtp.gmail.com with ESMTPSA id l81sm346278ywb.34.2016.06.23.08.30.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Jun 2016 08:30:18 -0700 (PDT) From: Gustavo Padovan To: dri-devel@lists.freedesktop.org Subject: [RFC 3/5] dma-buf/fence: add .get_fences() ops Date: Thu, 23 Jun 2016 12:29:48 -0300 Message-Id: <1466695790-2833-4-git-send-email-gustavo@padovan.org> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1466695790-2833-1-git-send-email-gustavo@padovan.org> References: <1466695790-2833-1-git-send-email-gustavo@padovan.org> Cc: marcheu@google.com, Daniel Stone , seanpaul@google.com, Daniel Vetter , linux-kernel@vger.kernel.org, laurent.pinchart@ideasonboard.com, Gustavo Padovan , John Harrison , m.chehab@samsung.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gustavo Padovan get_fences() should return a copy of all fences in the fence as some fence subclass (such as fence_array) can store more than one fence at time. Signed-off-by: Gustavo Padovan --- drivers/dma-buf/fence.c | 14 ++++++++++++++ include/linux/fence.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/drivers/dma-buf/fence.c b/drivers/dma-buf/fence.c index 4e61afb..f4094fd 100644 --- a/drivers/dma-buf/fence.c +++ b/drivers/dma-buf/fence.c @@ -185,6 +185,20 @@ void fence_release(struct kref *kref) } EXPORT_SYMBOL(fence_release); +struct fence **fence_get_fences(struct fence *fence) +{ + if (fence->ops->get_fences) { + return fence->ops->get_fences(fence); + } else { + struct fence **fences = kmalloc(sizeof(**fences), GFP_KERNEL); + if (!fences) + return NULL; + fences[0] = fence; + return fences; + } +} +EXPORT_SYMBOL(fence_get_fences); + void fence_teardown(struct fence *fence) { if (fence->ops->teardown) diff --git a/include/linux/fence.h b/include/linux/fence.h index 1d3b671..a7a2fbc 100644 --- a/include/linux/fence.h +++ b/include/linux/fence.h @@ -111,6 +111,7 @@ struct fence_cb { * struct fence_ops - operations implemented for fence * @get_driver_name: returns the driver name. * @get_timeline_name: return the name of the context this fence belongs to. + * @get_fences: return an array with a copy of all fences in the fence. * @enable_signaling: enable software signaling of fence. * @signaled: [optional] peek whether the fence is signaled, can be null. * @wait: custom wait implementation, or fence_default_wait. @@ -175,6 +176,7 @@ struct fence_cb { struct fence_ops { const char * (*get_driver_name)(struct fence *fence); const char * (*get_timeline_name)(struct fence *fence); + struct fence ** (*get_fences)(struct fence *fence); bool (*enable_signaling)(struct fence *fence); bool (*signaled)(struct fence *fence); signed long (*wait)(struct fence *fence, bool intr, signed long timeout); @@ -189,6 +191,7 @@ struct fence_ops { void fence_init(struct fence *fence, const struct fence_ops *ops, spinlock_t *lock, u64 context, unsigned seqno); +struct fence **fence_get_fences(struct fence *fence); void fence_release(struct kref *kref); void fence_teardown(struct fence *fence); void fence_free(struct fence *fence);