From patchwork Fri Jul 1 13:05:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9209855 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 A53A860752 for ; Fri, 1 Jul 2016 13:05:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95C7D2868E for ; Fri, 1 Jul 2016 13:05:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A6722869B; Fri, 1 Jul 2016 13:05:30 +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 181DD286AB for ; Fri, 1 Jul 2016 13:05:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 24BE96EA5F; Fri, 1 Jul 2016 13:05:29 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-f193.google.com (mail-qk0-f193.google.com [209.85.220.193]) by gabe.freedesktop.org (Postfix) with ESMTPS id 57D4D6EA5F for ; Fri, 1 Jul 2016 13:05:27 +0000 (UTC) Received: by mail-qk0-f193.google.com with SMTP id j2so23328739qkf.1 for ; Fri, 01 Jul 2016 06:05:27 -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=WhhYp/q7N76L/tZsb7pHovMgGfjP54N8o1eySOtHxwE=; b=L/ZDtFKRUX4UDzwS2X1sbI5FLS5yoLcl5F0vF3v+ejo5iCckDeiOdx89qy18cIjchn H5PKR6OO8kSrhbckHAusZ/0COFPYg6VJwztUxjQ3s6tWnH7n0d8liFQ0GWvrOLup/MQ+ SdLEPjbaO/JeRPJBh/yKsFPGYn8fUYkkbL+7CIsQe2rBW5eK9pzWajIT8eBCQjX2ct5i +z9/bHwdxSIEUuJryZOZwgiyAN/EbZ0gSsJM+uCifpTjgQPk9lm35SpAuqy/c04f/Qjo J18fDIk3mJzIcFnoMcxbXiL4t5wTUFxR5kp+/qpNJj17nglji6DR2UYKa6r2gyWJVVq9 D8RA== X-Gm-Message-State: ALyK8tLBZQPThggpjbeW1EFJyQcvEg9LjvKsNdir9HqFDz3YJd+FBHkYmtS9tBREY4YN/Q== X-Received: by 10.129.94.10 with SMTP id s10mr9242621ywb.307.1467378326379; Fri, 01 Jul 2016 06:05:26 -0700 (PDT) Received: from jade.localdomain ([189.61.225.79]) by smtp.gmail.com with ESMTPSA id g4sm6516973ywa.48.2016.07.01.06.05.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jul 2016 06:05:25 -0700 (PDT) From: Gustavo Padovan To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 3/4] dma-buf/sync_file: add sync_file_get_fence() Date: Fri, 1 Jul 2016 10:05:06 -0300 Message-Id: <1467378307-28088-4-git-send-email-gustavo@padovan.org> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1467378307-28088-1-git-send-email-gustavo@padovan.org> References: <1467378307-28088-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 Creates a function that given an sync file descriptor returns a fence containing all fences in the sync_file. v2: Comments by Daniel Vetter - Adapt to new version of fence_collection_init() - Hold a reference for the fence we return v3: - Adapt to use fput() directly - rename to sync_file_get_fence() as we always return one fence v4: Adapt to use fence_array Signed-off-by: Gustavo Padovan Reviewed-by: Chris Wilson --- drivers/dma-buf/sync_file.c | 24 ++++++++++++++++++++++++ include/linux/sync_file.h | 1 + 2 files changed, 25 insertions(+) diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c index 12dbf17..3ffaea8 100644 --- a/drivers/dma-buf/sync_file.c +++ b/drivers/dma-buf/sync_file.c @@ -116,6 +116,30 @@ err: return NULL; } +/** + * sync_file_get_fence - get the fence related to the sync_file fd + * @fd: sync_file fd to get the fence from + * + * Ensures @fd references a valid sync_file and returns a fence that + * represents all fence in the sync_file. On error NULL is returned. + */ +struct fence *sync_file_get_fence(int fd) +{ + struct sync_file *sync_file; + struct fence *fence; + + sync_file = sync_file_fdget(fd); + if (!sync_file) + return NULL; + + fence = sync_file->fence; + fence_get(fence); + fput(sync_file->file); + + return fence; +} +EXPORT_SYMBOL(sync_file_get_fence); + static int sync_file_set_fence(struct sync_file *sync_file, struct fence **fences, int num_fences) { diff --git a/include/linux/sync_file.h b/include/linux/sync_file.h index 2efc5ec..f7de5a0 100644 --- a/include/linux/sync_file.h +++ b/include/linux/sync_file.h @@ -46,5 +46,6 @@ struct sync_file { }; struct sync_file *sync_file_create(struct fence *fence); +struct fence *sync_file_get_fence(int fd); #endif /* _LINUX_SYNC_H */