From patchwork Tue Sep 12 20:42:12 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: 9950079 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 CFFB7602C9 for ; Tue, 12 Sep 2017 20:42:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1476289AC for ; Tue, 12 Sep 2017 20:42:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B592628C2E; Tue, 12 Sep 2017 20:42:26 +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 A6AE8289AC for ; Tue, 12 Sep 2017 20:42:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7CA4C6E099; Tue, 12 Sep 2017 20:42:23 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id EA6556E099; Tue, 12 Sep 2017 20:42:21 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id f4so9816789wmh.4; Tue, 12 Sep 2017 13:42:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=TUQNklKXQlOScw5hSJBlaNffl3eNk6alMv5zZ2FcX3o=; b=CLdoQzawaPrDjBlnCrxcPAp4E+xn4J8hLLpPsQSNOQjRYWN6SuMIzQzTwP66V7/Qry hok+qsx95MTv61Fv3zWwMtP0OaauiyiB7XTmgbPscIdf9ABj0MLHr/uqYWYcP7HaGwau +YAPQvqngvZViRhadPAdlaSV51Ri2j3aVhL8Fx+IM4QM6m0qdmWk6/ShtcZ/Fr07GdFI piOSF0qB+c4U5mj241OH1lU7kJGOC6biR1pPDFRKc3Qne97xkXpOeMsx4pIZQQONoUXf tSNbJ5DvMg0wYaQnrCqD4xqU5wsTqnlqK8t32gMmD7szX/9gZ/yW4urS2IdhySTbTtYA zA1w== 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:mime-version :content-transfer-encoding; bh=TUQNklKXQlOScw5hSJBlaNffl3eNk6alMv5zZ2FcX3o=; b=PCt78nHEIaC6iudSAo6psMskAgfrcRwZwl/sspoNwRoslN8V9fJZuKKE8d+lXVPsn/ O+EAzFNQMttST7xB1Xk7jBUc0O4OqmdAclmFyVJox6mD7RpPbFwRjncJ8vWGANM9Lypi OsoOLxeI0Odjw0p+I6ZLihsXdNsqE69O8sC8AIYZB3jAeLkNkOlMauoqv5WXERFS/Vp7 6QIUx0wpxqAcF57zFDoKtKXU4yRjIo8S6RptMrny1a354u50Ei72gRwQe5zg/UCGDwfo gnDpF66kskk3w90FOOJUBjjYOqhTxlOmzzPB6QtGkYz2Vg6FKMIj0envHEVexKTERXI1 UV5Q== X-Gm-Message-State: AHPjjUjH1QvnFmkeR633INwDuUtlp7+8+NT36MOz1r1gcd17456LJRpc He5aZM+IsSLYSU83YdFQGBkJ1Q== X-Google-Smtp-Source: AOwi7QAf/E8T63GijTX0QLi/eoD2ZRoek0zeYfenjRQPiwJJ+XeBKxlj0mVIY1V/8Fhbn0ZbvdlCpA== X-Received: by 10.28.59.215 with SMTP id i206mr586812wma.116.1505248940223; Tue, 12 Sep 2017 13:42:20 -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.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Sep 2017 13:42:19 -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 1/3] drm/syncobj: extract two helpers from drm_syncobj_create Date: Tue, 12 Sep 2017 22:42:12 +0200 Message-Id: <1505248934-1819-1-git-send-email-maraeo@gmail.com> X-Mailer: git-send-email 2.7.4 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 For amdgpu. drm_syncobj_create is renamed to drm_syncobj_create_as_handle, and new helpers drm_syncobj_create and drm_syncobj_get_handle are added. Signed-off-by: Marek Olšák --- drivers/gpu/drm/drm_syncobj.c | 49 +++++++++++++++++++++++++++++++++++++++---- include/drm/drm_syncobj.h | 4 ++++ 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index 0422b8c..0bb1741 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -262,8 +262,14 @@ void drm_syncobj_free(struct kref *kref) } EXPORT_SYMBOL(drm_syncobj_free); -static int drm_syncobj_create(struct drm_file *file_private, - u32 *handle, uint32_t flags) +/** + * drm_syncobj_create - create a new syncobj + * @out_syncobj: returned syncobj + * @flags: DRM_SYNCOBJ_* flags + * @fence: if non-NULL, the syncobj will represent this fence + */ +int drm_syncobj_create(struct drm_syncobj **out_syncobj, uint32_t flags, + struct dma_fence *fence) { int ret; struct drm_syncobj *syncobj; @@ -284,6 +290,25 @@ static int drm_syncobj_create(struct drm_file *file_private, } } + if (fence) + drm_syncobj_replace_fence(syncobj, fence); + + *out_syncobj = syncobj; + return 0; +} +EXPORT_SYMBOL(drm_syncobj_create); + +/** + * drm_syncobj_get_handle - get a handle from a syncobj + */ +int drm_syncobj_get_handle(struct drm_file *file_private, + struct drm_syncobj *syncobj, u32 *handle) +{ + int ret; + + /* take a reference to put in the idr */ + drm_syncobj_get(syncobj); + idr_preload(GFP_KERNEL); spin_lock(&file_private->syncobj_table_lock); ret = idr_alloc(&file_private->syncobj_idr, syncobj, 1, 0, GFP_NOWAIT); @@ -299,6 +324,22 @@ static int drm_syncobj_create(struct drm_file *file_private, *handle = ret; return 0; } +EXPORT_SYMBOL(drm_syncobj_get_handle); + +static int drm_syncobj_create_as_handle(struct drm_file *file_private, + u32 *handle, uint32_t flags) +{ + int ret; + struct drm_syncobj *syncobj; + + ret = drm_syncobj_create(&syncobj, flags, NULL); + if (ret) + return ret; + + ret = drm_syncobj_get_handle(file_private, syncobj, handle); + drm_syncobj_put(syncobj); + return ret; +} static int drm_syncobj_destroy(struct drm_file *file_private, u32 handle) @@ -522,8 +563,8 @@ drm_syncobj_create_ioctl(struct drm_device *dev, void *data, if (args->flags & ~DRM_SYNCOBJ_CREATE_SIGNALED) return -EINVAL; - return drm_syncobj_create(file_private, - &args->handle, args->flags); + return drm_syncobj_create_as_handle(file_private, + &args->handle, args->flags); } int diff --git a/include/drm/drm_syncobj.h b/include/drm/drm_syncobj.h index c00fee5..e7f0035 100644 --- a/include/drm/drm_syncobj.h +++ b/include/drm/drm_syncobj.h @@ -136,5 +136,9 @@ int drm_syncobj_find_fence(struct drm_file *file_private, u32 handle, struct dma_fence **fence); void drm_syncobj_free(struct kref *kref); +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); #endif