From patchwork Mon Aug 7 21:32:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 9886247 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 5D3F7602CC for ; Mon, 7 Aug 2017 21:32:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F3E82870F for ; Mon, 7 Aug 2017 21:32:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4422A28714; Mon, 7 Aug 2017 21:32:43 +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=-2.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, 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 052012870F for ; Mon, 7 Aug 2017 21:32:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C61C589FE6; Mon, 7 Aug 2017 21:32:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-it0-x244.google.com (mail-it0-x244.google.com [IPv6:2607:f8b0:4001:c0b::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 73CFA89FA5; Mon, 7 Aug 2017 21:32:37 +0000 (UTC) Received: by mail-it0-x244.google.com with SMTP id f16so1215686itb.5; Mon, 07 Aug 2017 14:32:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0CrFGXLBGi6JIkVfUj3xAta7XTXJo4V0AqhclkLARfI=; b=hgKuX50ySeqXYHX4apy0ZH2GTooCYWD/cY2M03xknticdcKed9JD9SCiqNTyG3EDMH BRDlqBdPIpZRyMjVguw7wdTkktbBG+AaIYXkPwo4FfbVRfB2Vgq8ss4jeAqTWOgXZve3 BaI3HMaWDCU/rQiAUtTW3BWOVXRQZW9uXlHbrMoqQrbB48D2C/0xpyXoesCHj7EnMO88 ENURALjvYeJSBk1UBGm9RRo8ZdXbrd5sQFBqH6149BLzZEHNrlbl5XZCM6vuVmeqglKx QuamSfpgoHob4ce8+cn+3v9n5zYsQ3AWRj4yIlgGKut4YU2lKvTky7WyJzirsqprhjJH EKKQ== 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:mime-version:content-transfer-encoding; bh=0CrFGXLBGi6JIkVfUj3xAta7XTXJo4V0AqhclkLARfI=; b=iKSVXDXSPifnpn/wFo1k0EAjSnJyhxqu69wou6MgIZDV1BA5Ye0Oa2AhtiKHpR4GZm jIgX8YzKIVznvPCp4NILs5BNS+jPmzjGLKLsZGS0g8tNgsP0OgdLip89103hrPcyLq4K J3JGXymBfIoKOsYhDOpk7lM8zpvl93vcViEdgEksT6dWk3x+E7GusYYP1OkCmfbK2c7r ZqjM4aSZF+XiFVpyHdRwZleunssP3qpL2ukweJTHDXnhe+m9asOnhxz/f7rlIp7y3YS1 hZWqAwNtbQ2QyOcZQJCdn9rCcdbdsuu4r0hKJbyBG7KY21c4dqch7ILUGYm/GJZNbjO8 Xotw== X-Gm-Message-State: AHYfb5gdKXAz7abosXWlLX8+/ASy3tyHd7qvlweHmC10j0fRDLXJwV7b 0L2C2cpg7mAXUx7V X-Received: by 10.36.115.66 with SMTP id y63mr2116441itb.46.1502141556660; Mon, 07 Aug 2017 14:32:36 -0700 (PDT) Received: from cm.amd.com ([165.204.55.251]) by smtp.gmail.com with ESMTPSA id x131sm24302itf.17.2017.08.07.14.32.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 14:32:36 -0700 (PDT) From: Alex Deucher X-Google-Original-From: Alex Deucher To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, sumit.semwal@linaro.org, christian.koenig@amd.com Subject: [PATCH 3/3] dma-buf: fix reservation_object_wait_timeout_rcu to wait correctly v2 Date: Mon, 7 Aug 2017 17:32:23 -0400 Message-Id: <1502141543-13455-4-git-send-email-alexander.deucher@amd.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1502141543-13455-1-git-send-email-alexander.deucher@amd.com> References: <1502141543-13455-1-git-send-email-alexander.deucher@amd.com> MIME-Version: 1.0 Cc: Alex Deucher 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: Christian König With hardware resets in mind it is possible that all shared fences are signaled, but the exlusive isn't. Fix waiting for everything in this situation. v2: make sure we always wait for the exclusive fence Signed-off-by: Christian König Reviewed-by: Alex Deucher Reviewed-by: Chunming Zhou Signed-off-by: Alex Deucher --- drivers/dma-buf/reservation.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index e2eff86..302c137 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -429,12 +429,25 @@ long reservation_object_wait_timeout_rcu(struct reservation_object *obj, long ret = timeout ? timeout : 1; retry: - fence = NULL; shared_count = 0; seq = read_seqcount_begin(&obj->seq); rcu_read_lock(); - if (wait_all) { + fence = rcu_dereference(obj->fence_excl); + if (fence && !test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) { + if (!dma_fence_get_rcu(fence)) + goto unlock_retry; + + if (dma_fence_is_signaled(fence)) { + dma_fence_put(fence); + fence = NULL; + } + + } else { + fence = NULL; + } + + if (!fence && wait_all) { struct reservation_object_list *fobj = rcu_dereference(obj->fence); @@ -461,22 +474,6 @@ long reservation_object_wait_timeout_rcu(struct reservation_object *obj, } } - if (!shared_count) { - struct dma_fence *fence_excl = rcu_dereference(obj->fence_excl); - - if (fence_excl && - !test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, - &fence_excl->flags)) { - if (!dma_fence_get_rcu(fence_excl)) - goto unlock_retry; - - if (dma_fence_is_signaled(fence_excl)) - dma_fence_put(fence_excl); - else - fence = fence_excl; - } - } - rcu_read_unlock(); if (fence) { if (read_seqcount_retry(&obj->seq, seq)) {