From patchwork Tue Sep 12 20:42:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWFyZWsgT2zFocOhaw==?= X-Patchwork-Id: 9950083 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 6F552602C9 for ; Tue, 12 Sep 2017 20:42:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61675289AC for ; Tue, 12 Sep 2017 20:42:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5636F28C2E; Tue, 12 Sep 2017 20:42:29 +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.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 19E93289AC for ; Tue, 12 Sep 2017 20:42:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 03F3A6E712; Tue, 12 Sep 2017 20:42:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id E87CF6E099; Tue, 12 Sep 2017 20:42:22 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id x17so9826512wmd.5; Tue, 12 Sep 2017 13:42:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=X+EfNgbBPg6rRYRYD2o61MRo5Dxs1wkQXCAXNmc1ASM=; b=fUQoaKxoberGuxDloTC4FwVtY7Em4MbsZA3z6WYUQddv23IkvgIIx7tg6cqdjIYL7+ +/rEmYZbamMDuKtgvkGggBGTHLaqxo/b8cIYtdfhh4yhPW52GtCc1BzlUekYBSy6FDzx Q1p10aPF0FGrJR74So8mUuomztI1UlWeQ71fw8grWGeK0CWRSbj+dPGBOIW4dI0v+Npm u1vR+nmEETu9qRZXxuSCi+dDdJOOwYQGtOFQ0MuRKeocZIPN8v5ADnDH+vCNNsg/nzwv HLeTEI3Qc+ia8/AVCACRihIGPlDJJehGMMEHWrMt+PlxvFmFXhKGLBUSzr9dGE27muA4 vgSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X+EfNgbBPg6rRYRYD2o61MRo5Dxs1wkQXCAXNmc1ASM=; b=YUHtXf3oNUKWO88Vkiy8Vj5Myk4AOboQBZOZu6UgJ1G8wVPM59MLE7eIuDFCkoXzvn /zTIQRo9lRKms4LIOiLiIbUWCxxxu11stBXZKCJeZxwRjA2tfk0CU1klcpsWAPYA6rVN DBcPNpEHzlqOZt2a/G7ZDWj61GwKwDrrheITwam3caLvs1861cfiagFA7PCH1t2/indP YuiprjecVNNmlRrWacZoTvYxLbonj0J4+JzzmfhhJr+beDKPCjEKVeU4MQWnijozdAff h4KMy/BmEBxpSY2XcG0vL4yzztOOPP+df6OvKBPr0vmrFONNV508dzxlUNHmN+PmMioV p6Ow== X-Gm-Message-State: AHPjjUj+xMxASwjbC5TgLA0ke79G3Hxef8UAu3BaMJiR8Koy9TV/4J0y UJrl1/jj/e2C73ZA6Mv+DS85kA== X-Google-Smtp-Source: AOwi7QDHqnyDXjpYgxsLb7GZUX8fH5LLqgQBHianY7Z5vxknmxQ4vksuZ3NoAeOLRypcPcuYLx615g== X-Received: by 10.28.111.71 with SMTP id k68mr668228wmc.64.1505248941130; Tue, 12 Sep 2017 13:42:21 -0700 (PDT) Received: from localhost.localdomain (ip-78-102-146-217.net.upcbroadband.cz. [78.102.146.217]) by smtp.gmail.com with ESMTPSA id 29sm19983487wrz.77.2017.09.12.13.42.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Sep 2017 13:42:20 -0700 (PDT) From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH 2/3] drm/syncobj: add a new helper drm_syncobj_get_fd Date: Tue, 12 Sep 2017 22:42:13 +0200 Message-Id: <1505248934-1819-2-git-send-email-maraeo@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505248934-1819-1-git-send-email-maraeo@gmail.com> References: <1505248934-1819-1-git-send-email-maraeo@gmail.com> MIME-Version: 1.0 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Marek Olšák Signed-off-by: Marek Olšák --- drivers/gpu/drm/drm_syncobj.c | 33 +++++++++++++++++++-------------- include/drm/drm_syncobj.h | 1 + 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index 0bb1741..62adc7a 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -386,33 +386,38 @@ static int drm_syncobj_alloc_file(struct drm_syncobj *syncobj) return 0; } -static int drm_syncobj_handle_to_fd(struct drm_file *file_private, - u32 handle, int *p_fd) +int drm_syncobj_get_fd(struct drm_syncobj *syncobj, int *p_fd) { - struct drm_syncobj *syncobj = drm_syncobj_find(file_private, handle); int ret; int fd; - if (!syncobj) - return -EINVAL; - fd = get_unused_fd_flags(O_CLOEXEC); - if (fd < 0) { - drm_syncobj_put(syncobj); + if (fd < 0) return fd; - } if (!syncobj->file) { ret = drm_syncobj_alloc_file(syncobj); - if (ret) - goto out_put_fd; + if (ret) { + put_unused_fd(fd); + return ret; + } } fd_install(fd, syncobj->file); - drm_syncobj_put(syncobj); *p_fd = fd; return 0; -out_put_fd: - put_unused_fd(fd); +} +EXPORT_SYMBOL(drm_syncobj_get_fd); + +static int drm_syncobj_handle_to_fd(struct drm_file *file_private, + u32 handle, int *p_fd) +{ + struct drm_syncobj *syncobj = drm_syncobj_find(file_private, handle); + int ret; + + if (!syncobj) + return -EINVAL; + + ret = drm_syncobj_get_fd(syncobj, p_fd); drm_syncobj_put(syncobj); return ret; } diff --git a/include/drm/drm_syncobj.h b/include/drm/drm_syncobj.h index e7f0035..43e2f38 100644 --- a/include/drm/drm_syncobj.h +++ b/include/drm/drm_syncobj.h @@ -140,5 +140,6 @@ int drm_syncobj_create(struct drm_syncobj **out_syncobj, uint32_t flags, struct dma_fence *fence); int drm_syncobj_get_handle(struct drm_file *file_private, struct drm_syncobj *syncobj, u32 *handle); +int drm_syncobj_get_fd(struct drm_syncobj *syncobj, int *p_fd); #endif