From patchwork Wed May 9 20:14:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 10391585 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 8BD3F60153 for ; Thu, 10 May 2018 10:18:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BA82289A9 for ; Thu, 10 May 2018 10:18:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70A60289C6; Thu, 10 May 2018 10:18:48 +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,UNPARSEABLE_RELAY 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 9F5D5289A9 for ; Thu, 10 May 2018 10:18:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EA4906EEE0; Thu, 10 May 2018 10:18:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1F5326E004 for ; Wed, 9 May 2018 20:16:15 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 848842864AB From: Ezequiel Garcia To: Sumit Semwal , Gustavo Padovan Subject: [PATCH] dma-fence: Make dma_fence_add_callback() fail if signaled with error Date: Wed, 9 May 2018 17:14:49 -0300 Message-Id: <20180509201449.27452-1-ezequiel@collabora.com> X-Mailer: git-send-email 2.16.3 X-Mailman-Approved-At: Thu, 10 May 2018 10:17:43 +0000 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: kernel@collabora.com, Ezequiel Garcia , dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Change how dma_fence_add_callback() behaves, when the fence has error-signaled by the time it is being add. After this commit, dma_fence_add_callback() returns the fence error, if it has error-signaled before dma_fence_add_callback() is called. Signed-off-by: Ezequiel Garcia --- drivers/dma-buf/dma-fence.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c index 4edb9fd3cf47..298b440c5b68 100644 --- a/drivers/dma-buf/dma-fence.c +++ b/drivers/dma-buf/dma-fence.c @@ -226,7 +226,8 @@ EXPORT_SYMBOL(dma_fence_enable_sw_signaling); * * Note that the callback can be called from an atomic context. If * fence is already signaled, this function will return -ENOENT (and - * *not* call the callback) + * *not* call the callback). If the fence is error-signaled, this + * function returns the fence error. * * Add a software callback to the fence. Same restrictions apply to * refcount as it does to dma_fence_wait, however the caller doesn't need to @@ -235,8 +236,8 @@ EXPORT_SYMBOL(dma_fence_enable_sw_signaling); * after it signals with dma_fence_signal. The callback itself can be called * from irq context. * - * Returns 0 in case of success, -ENOENT if the fence is already signaled - * and -EINVAL in case of error. + * Returns 0 in case of success, -ENOENT (or the error value) if the fence is + * already signaled and -EINVAL in case of error. */ int dma_fence_add_callback(struct dma_fence *fence, struct dma_fence_cb *cb, dma_fence_func_t func) @@ -250,7 +251,8 @@ int dma_fence_add_callback(struct dma_fence *fence, struct dma_fence_cb *cb, if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) { INIT_LIST_HEAD(&cb->node); - return -ENOENT; + ret = (fence->error < 0) ? fence->error : -ENOENT; + return ret; } spin_lock_irqsave(fence->lock, flags);