From patchwork Wed Mar 23 18:47:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 8653151 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C463FC0553 for ; Wed, 23 Mar 2016 18:47:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DE7A0202E5 for ; Wed, 23 Mar 2016 18:47:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 135C12026D for ; Wed, 23 Mar 2016 18:47:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D74956E908; Wed, 23 Mar 2016 18:47:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yw0-f178.google.com (mail-yw0-f178.google.com [209.85.161.178]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5FF4F6E901 for ; Wed, 23 Mar 2016 18:47:48 +0000 (UTC) Received: by mail-yw0-f178.google.com with SMTP id g3so31124758ywa.3 for ; Wed, 23 Mar 2016 11:47:48 -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=N5g2YUyTxz3k0YDxmxs5yYTPzcYVxC2pTtUNaFeLyvE=; b=EPlKeP3cm1k8DRfNu+xZ7i/dAF5OFAYwR+uVbYFTzy1rYxDw1T3ihhvhusGs0aeyt9 jl9Ucy5jvdRVQ4nDQuXrl4+DZYqezydhZmO/qTR/Z5+VlF7diprCd3Bf+1OPiNA1hSjk w+odYkooNMNXCIhvINLUovBGxvHDccsVtK42MrbfkQ4t2iuh5Q6RUX8JswxYBAtkabox 9+FBUUc6g4wVHlTwrTSwUO9THSubb45SZm/rvf5D4fBQc/3m27LapjKZ4SzaozAePHRZ B63BHQRxxK5dXEtnB5UaWGnICfxTcrTybYWVoCt5WnQ4bKrDOM1Ip+iaPi025BzSqlBU hCiA== X-Gm-Message-State: AD7BkJIexymwcjYcsKeHHBpe1a+qe5gC45WZ1HSRqs4AELhg1Nd6t0Lk/mK7w/D5et5n0Q== X-Received: by 10.37.230.88 with SMTP id d85mr2293127ybh.15.1458758866283; Wed, 23 Mar 2016 11:47:46 -0700 (PDT) Received: from jade.localdomain ([201.82.24.203]) by smtp.gmail.com with ESMTPSA id y138sm2146629ywa.28.2016.03.23.11.47.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Mar 2016 11:47:45 -0700 (PDT) From: Gustavo Padovan To: dri-devel@lists.freedesktop.org Subject: [RFC 5/6] dma-buf/fence: add fence_collection_wait() Date: Wed, 23 Mar 2016 15:47:26 -0300 Message-Id: <1458758847-21170-6-git-send-email-gustavo@padovan.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1458758847-21170-1-git-send-email-gustavo@padovan.org> References: <1458758847-21170-1-git-send-email-gustavo@padovan.org> Cc: Daniel Stone , Daniel Vetter , =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , linux-kernel@vger.kernel.org, Riley Andrews , Gustavo Padovan , John Harrison 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 From: Gustavo Padovan Iterate over the array of fences and wait for all of the to finish. Signed-off-by: Gustavo Padovan --- drivers/dma-buf/fence.c | 16 ++++++++++++++++ include/linux/fence.h | 1 + 2 files changed, 17 insertions(+) diff --git a/drivers/dma-buf/fence.c b/drivers/dma-buf/fence.c index a3fe3e7..31e554b 100644 --- a/drivers/dma-buf/fence.c +++ b/drivers/dma-buf/fence.c @@ -532,6 +532,22 @@ fence_init(struct fence *fence, const struct fence_ops *ops, EXPORT_SYMBOL(fence_init); /** + * fence_collection_wait - Wait for collection of fences to signal + * @collection: [in] the collection to wait on + * + * This functions simplifies the waiting process when one needs to + * wait for many fences at the same time. + */ +void fence_collection_wait(struct fence_collection *collection) +{ + int i; + + for (i = 0 ; i < collection->num_fences ; i++) + fence_wait(collection->fences[i], false); +} +EXPORT_SYMBOL(fence_collection_wait); + +/** * fence_collection_put - put all the fences in a collection * @collection: [in] the collection to put fences * diff --git a/include/linux/fence.h b/include/linux/fence.h index 3f871b0..52f1aea 100644 --- a/include/linux/fence.h +++ b/include/linux/fence.h @@ -244,6 +244,7 @@ int fence_add_callback(struct fence *fence, struct fence_cb *cb, bool fence_remove_callback(struct fence *fence, struct fence_cb *cb); void fence_enable_sw_signaling(struct fence *fence); +void fence_collection_wait(struct fence_collection *collection); void fence_collection_put(struct fence_collection *collection); /**