From patchwork Sun Aug 11 09:15:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 11088877 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 29F136C5 for ; Sun, 11 Aug 2019 09:15:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FAF8201F3 for ; Sun, 11 Aug 2019 09:15:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03162223A1; Sun, 11 Aug 2019 09:15:39 +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,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 79CE0202A5 for ; Sun, 11 Aug 2019 09:15:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 136556E30F; Sun, 11 Aug 2019 09:15:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 25E686E30F; Sun, 11 Aug 2019 09:15:36 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 17958643-1500050 for multiple; Sun, 11 Aug 2019 10:15:25 +0100 From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH 5/4] dma-fence: Have dma_fence_signal call signal_locked Date: Sun, 11 Aug 2019 10:15:23 +0100 Message-Id: <20190811091523.9382-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <3b4da1e6-b5df-0f0e-cf4d-21dd6fd33e32@amd.com> References: <3b4da1e6-b5df-0f0e-cf4d-21dd6fd33e32@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: , Cc: intel-gfx@lists.freedesktop.org, =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Now that dma_fence_signal always takes the spinlock to flush the cb_list, simply take the spinlock and call dma_fence_signal_locked() to avoid code repetition. Suggested-by: Christian König Signed-off-by: Chris Wilson Cc: Christian König Reviewed-by: Christian König --- drivers/dma-buf/dma-fence.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c index ab4a456bba04..367b71084d34 100644 --- a/drivers/dma-buf/dma-fence.c +++ b/drivers/dma-buf/dma-fence.c @@ -122,26 +122,18 @@ EXPORT_SYMBOL(dma_fence_context_alloc); */ int dma_fence_signal_locked(struct dma_fence *fence) { - int ret = 0; - - lockdep_assert_held(fence->lock); - if (WARN_ON(!fence)) return -EINVAL; - if (!__dma_fence_signal(fence)) { - ret = -EINVAL; + lockdep_assert_held(fence->lock); - /* - * we might have raced with the unlocked dma_fence_signal, - * still run through all callbacks - */ - } else { - __dma_fence_signal__timestamp(fence, ktime_get()); - } + if (!__dma_fence_signal(fence)) + return -EINVAL; + __dma_fence_signal__timestamp(fence, ktime_get()); __dma_fence_signal__notify(fence); - return ret; + + return 0; } EXPORT_SYMBOL(dma_fence_signal_locked); @@ -161,19 +153,19 @@ EXPORT_SYMBOL(dma_fence_signal_locked); int dma_fence_signal(struct dma_fence *fence) { unsigned long flags; + int ret; if (!fence) return -EINVAL; - if (!__dma_fence_signal(fence)) - return -EINVAL; - - __dma_fence_signal__timestamp(fence, ktime_get()); + if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) + return 0; spin_lock_irqsave(fence->lock, flags); - __dma_fence_signal__notify(fence); + ret = dma_fence_signal_locked(fence); spin_unlock_irqrestore(fence->lock, flags); - return 0; + + return ret; } EXPORT_SYMBOL(dma_fence_signal);