From patchwork Mon Dec 3 13:07:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 10709523 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E2DB13BF for ; Mon, 3 Dec 2018 13:08:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F8E229755 for ; Mon, 3 Dec 2018 13:08:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83BBC2B435; Mon, 3 Dec 2018 13:08:10 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 325D129755 for ; Mon, 3 Dec 2018 13:08:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7705B89E11; Mon, 3 Dec 2018 13:08:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by gabe.freedesktop.org (Postfix) with ESMTPS id 09A7F89E01; Mon, 3 Dec 2018 13:08:03 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id r24so6943608wmh.0; Mon, 03 Dec 2018 05:08:02 -0800 (PST) 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=IxyRs9amVxhioCR0yK7zeeZdXRKYWLS4dIninHcgA+0=; b=NS8Kulf2TeL70wIn8xKXc0/j4mSUSCT3Rj4OPHVTWADFOp3dL1ePm0jhIgDFgKj2LB pPexpkbqpIKkKlA/ktR/48YYugsfsjB0WuaoBOAfvrghFxudwjbFlmQ42LErYL2yd6Aw a+6CzxgVvqgvCwAY2dwuxQTRsI7wrJFo+5JBDaci1kd4/ufVLGYRg94drn7fUsqMB2Nj br9J6gMcWB/hFPaTUr5+0ee0mHTRdoXRmk5jeT50k7JN2XW3KswG9vyc3hJvqG8Ba9sM nRHDmqd2Uc1dOAC+HF9UikwVXXLCu3PqV4NkrWZkVwCXIcVPKv6INM6PPAmv+tavXt0v RkVg== X-Gm-Message-State: AA+aEWb6zihs8ZHcZQCLkgKyDJc2kWBL7b24AZJ6G9UTdzKojmtct3Vf dm0KOybcxZ+6giYe9wSjwGr0FULS X-Google-Smtp-Source: AFSGD/UjgRJlZaGWPuUonSASNFKTcpPdjkCENp/ycz14QVsKwrmF187Iw97xn5jtCrfdZQvNDLGBRA== X-Received: by 2002:a1c:cc19:: with SMTP id h25mr8160632wmb.80.1543842481478; Mon, 03 Dec 2018 05:08:01 -0800 (PST) Received: from baker.fritz.box ([2a02:908:125b:9a00:198f:f629:ddd7:aabf]) by smtp.gmail.com with ESMTPSA id s16sm15469519wrt.77.2018.12.03.05.08.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Dec 2018 05:08:01 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH 2/3] drm/syncobj: use dma_fence_get_stub Date: Mon, 3 Dec 2018 14:07:58 +0100 Message-Id: <20181203130759.10226-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20181203130759.10226-1-christian.koenig@amd.com> References: <20181203130759.10226-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 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 Extract of useful code from the timeline work. Let's use just a single stub fence instance instead of allocating a new one all the time. Signed-off-by: Chunming Zhou Signed-off-by: Christian König Reviewed-by: Chris Wilson --- drivers/gpu/drm/drm_syncobj.c | 58 +++++++++++-------------------------------- 1 file changed, 14 insertions(+), 44 deletions(-) diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index e2c5b3ca4824..5c5ba1f14307 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -56,22 +56,6 @@ #include "drm_internal.h" #include -struct drm_syncobj_stub_fence { - struct dma_fence base; - spinlock_t lock; -}; - -static const char *drm_syncobj_stub_fence_get_name(struct dma_fence *fence) -{ - return "syncobjstub"; -} - -static const struct dma_fence_ops drm_syncobj_stub_fence_ops = { - .get_driver_name = drm_syncobj_stub_fence_get_name, - .get_timeline_name = drm_syncobj_stub_fence_get_name, -}; - - /** * drm_syncobj_find - lookup and reference a sync object. * @file_private: drm file private pointer @@ -190,23 +174,18 @@ void drm_syncobj_replace_fence(struct drm_syncobj *syncobj, } EXPORT_SYMBOL(drm_syncobj_replace_fence); -static int drm_syncobj_assign_null_handle(struct drm_syncobj *syncobj) +/** + * drm_syncobj_assign_null_handle - assign a stub fence to the sync object + * @syncobj: sync object to assign the fence on + * + * Assign a already signaled stub fence to the sync object. + */ +static void drm_syncobj_assign_null_handle(struct drm_syncobj *syncobj) { - struct drm_syncobj_stub_fence *fence; - fence = kzalloc(sizeof(*fence), GFP_KERNEL); - if (fence == NULL) - return -ENOMEM; + struct dma_fence *fence = dma_fence_get_stub(); - spin_lock_init(&fence->lock); - dma_fence_init(&fence->base, &drm_syncobj_stub_fence_ops, - &fence->lock, 0, 0); - dma_fence_signal(&fence->base); - - drm_syncobj_replace_fence(syncobj, 0, &fence->base); - - dma_fence_put(&fence->base); - - return 0; + drm_syncobj_replace_fence(syncobj, 0, fence); + dma_fence_put(fence); } /** @@ -274,7 +253,6 @@ EXPORT_SYMBOL(drm_syncobj_free); int drm_syncobj_create(struct drm_syncobj **out_syncobj, uint32_t flags, struct dma_fence *fence) { - int ret; struct drm_syncobj *syncobj; syncobj = kzalloc(sizeof(struct drm_syncobj), GFP_KERNEL); @@ -285,13 +263,8 @@ int drm_syncobj_create(struct drm_syncobj **out_syncobj, uint32_t flags, INIT_LIST_HEAD(&syncobj->cb_list); spin_lock_init(&syncobj->lock); - if (flags & DRM_SYNCOBJ_CREATE_SIGNALED) { - ret = drm_syncobj_assign_null_handle(syncobj); - if (ret < 0) { - drm_syncobj_put(syncobj); - return ret; - } - } + if (flags & DRM_SYNCOBJ_CREATE_SIGNALED) + drm_syncobj_assign_null_handle(syncobj); if (fence) drm_syncobj_replace_fence(syncobj, 0, fence); @@ -982,11 +955,8 @@ drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, if (ret < 0) return ret; - for (i = 0; i < args->count_handles; i++) { - ret = drm_syncobj_assign_null_handle(syncobjs[i]); - if (ret < 0) - break; - } + for (i = 0; i < args->count_handles; i++) + drm_syncobj_assign_null_handle(syncobjs[i]); drm_syncobj_array_free(syncobjs, args->count_handles);