From patchwork Fri Aug 11 22:39:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Ekstrand X-Patchwork-Id: 9896701 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 0095860351 for ; Fri, 11 Aug 2017 22:40:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E790D28CAC for ; Fri, 11 Aug 2017 22:40:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC84228CFE; Fri, 11 Aug 2017 22:40:08 +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_SIGNED, 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 80AF728CAC for ; Fri, 11 Aug 2017 22:40:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 70C966E76F; Fri, 11 Aug 2017 22:39:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 699086E76C for ; Fri, 11 Aug 2017 22:39:55 +0000 (UTC) Received: by mail-pf0-x243.google.com with SMTP id t83so4522673pfj.3 for ; Fri, 11 Aug 2017 15:39:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jlekstrand-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=i+an637inCpbB1aUezrMa5H8xINxz79Xy5dPxa/xNpQ=; b=pG16QcygC9aNJDhvtHC1FEzljO3P1i1HNUU6kHDnTQwr7Y701lZQ502hbCy0BOlWiZ iyOfvPapWPZKkeT/xO/E8qGOdqbGeY2GRg0vCUHj29DJypxGgmP0C8NK5K5Oc67CVexQ GFPdTeoUZPUsjV0P8ZVZ0AIM+K15kry7VKl82P/saRqxMF4xL0WjCbPh+4UUTpDdkkaG +Mr/71kf15mG3ygM/BryZtx+kQZK2iRZTe2esYBpFDnM9PrzyAn5A5gA6ONXpp+cKbY6 16/7ffqPY7a2iMdQnEweUNHt96t6U4piZXFYokHn+7eIdiW2TvBbipeJAxMXUV+mP+vd LOsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=i+an637inCpbB1aUezrMa5H8xINxz79Xy5dPxa/xNpQ=; b=a4AtEOlgfmDQ52Oans8nNXOa19HrExWQxFadgdEA1oyBP4Eh/9+K5kLD8mEK08H6B9 QQeySrWT5TfJJmujDBoZI2vRJV9ZrBSSkvh1c2EUpC4PPEnPSdwKRuBaUJkBsCDQBnfT CHYBYsM1WdsuS2H/wC50o+BzSbfSIB+RlTH1nhcmJrfRp0sU2pNEoNH5ZNb3kCcRkJTj jjrHkLE6ZZHfGJZnhC/CKw96DPHuQk8y8+ArCii7zuIllD80+str6AKpMzuTYTl/VzEh ya9mGSNoFS0uLen8JBNyLbDoljYV6s0p560KuAfpOkqpaAIdi3srH0xUwmSkctqiMdF4 Z9nA== X-Gm-Message-State: AHYfb5hQ6xS6WUpSUdbavE6+lTqga8m7kms7okn8gdhhqgBAkHLiW+tM 7a/NxV+dleM3MXh/9R/+Pw== X-Received: by 10.84.234.15 with SMTP id m15mr19666142plk.247.1502491194694; Fri, 11 Aug 2017 15:39:54 -0700 (PDT) Received: from omlet.jf.intel.com (fmdmzpr03-ext.fm.intel.com. [192.55.54.38]) by smtp.gmail.com with ESMTPSA id p77sm3244484pfi.153.2017.08.11.15.39.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Aug 2017 15:39:53 -0700 (PDT) From: Jason Ekstrand X-Google-Original-From: Jason Ekstrand To: dri-devel@lists.freedesktop.org Subject: [PATCH 7/9] dma-buf/dma-fence: Signal all callbacks from dma_fence_release() Date: Fri, 11 Aug 2017 15:39:32 -0700 Message-Id: <1502491174-10913-8-git-send-email-jason.ekstrand@intel.com> X-Mailer: git-send-email 2.5.0.400.gff86faf In-Reply-To: <1502491174-10913-1-git-send-email-jason.ekstrand@intel.com> References: <1502232369-19753-1-git-send-email-jason.ekstrand@intel.com> <1502491174-10913-1-git-send-email-jason.ekstrand@intel.com> 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Chris Wilson This is an illegal scenario, to free the fence whilst there are pending callbacks. Currently, we emit a WARN and then cast aside the callbacks leaving them dangling. Alternatively, we could set an error on the fence and then signal fence so that any dependency chains from the fence can be tidied up, and if they care they can check for the error. The question is whether or not the cure is worse than the disease (premature fence signaling is never pretty). Signed-off-by: Chris Wilson Reviewed-by: Gustavo Padovan --- drivers/dma-buf/dma-fence.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c index 0cac367..4062708 100644 --- a/drivers/dma-buf/dma-fence.c +++ b/drivers/dma-buf/dma-fence.c @@ -172,7 +172,19 @@ void dma_fence_release(struct kref *kref) trace_dma_fence_destroy(fence); - WARN_ON(!list_empty(&fence->cb_list)); + if (WARN_ON(!list_empty(&fence->cb_list))) { + unsigned long flags; + + /* + * This should never happen, but if it does make sure that we + * don't leave chains dangling. We set the error flag first + * so that the callbacks know this signal is due to an error. + */ + spin_lock_irqsave(fence->lock, flags); + fence->error = -EDEADLK; + dma_fence_signal_locked(fence); + spin_unlock_irqrestore(fence->lock, flags); + } if (fence->ops->release) fence->ops->release(fence);