From patchwork Thu Aug 10 17:01:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 9894263 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 830D360384 for ; Thu, 10 Aug 2017 17:02:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72AAE28B23 for ; Thu, 10 Aug 2017 17:02:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 674FE28B71; Thu, 10 Aug 2017 17:02: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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 2C44B28B27 for ; Thu, 10 Aug 2017 17:02:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B2BBA6E5DB; Thu, 10 Aug 2017 17:02:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt0-x242.google.com (mail-qt0-x242.google.com [IPv6:2607:f8b0:400d:c0d::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 233766E5D7; Thu, 10 Aug 2017 17:02:02 +0000 (UTC) Received: by mail-qt0-x242.google.com with SMTP id t37so1294211qtg.2; Thu, 10 Aug 2017 10:02:02 -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=vgSBhfZJAs+HHhdQKYSheuDigAwKmFWfDAse8x5FvUU=; b=jXkxkivCKwzF8/50u7hEAFR8mopcxIirMuW46eTA1E8evU6oOJQt/U3issMgZuXEsT fZ1RjiiGYSV0VhPfnxBEeAKjCfX1GiajrdEAxQGWVEzka+PX4Bi6EnlJUgTB6FWWT2Cn 0i3MekMxiU3m+w2MC+Jg0k8+cs5TTLKpJ/vnCUve0h+s92vBq57557hxvxN0+dk0yW+l uCuvvhG3YucaEWswFv+AT0DarfM6L0hElaEblyRidL7nufzO98B330DQMCcvCxH+2cKd oh3yOWr25leWppjBPXCzqESQYkFEMDF+f7geEDkYKX/yhQo9UQ1UazRdF+kAbwO3epci YDTg== 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=vgSBhfZJAs+HHhdQKYSheuDigAwKmFWfDAse8x5FvUU=; b=ANqk5AYIh1XDKSvT/11ja6gq3Nq1XvgG+pHwO9j+OvyZf5UJefbfxgOnpWgYMCI/NK RUXfKM6v8pONC/K46Tm671zeCO1WV8NmuehfHFZzNcHMSlaD76mtZcJGRJjeYwA2ycYN VUJytaaeufM+6mAOKjnbRqet+yMKn2+erYl6WzhAVJXzDx+XZ374xhRagWWPPHO02qCa BWm3iZmxsK9STCXUIXMwspN1xdJg+X9x9Xx8cTCz4g46qYwLjqk0KwDZqnEnPipzhROZ q9ql1cUxFoM0b5QmFu+jyC9FVFwMCnb+5scxQ/PmXx+c4n11IyhNn3SjQRdKiEO63Xj9 Thgw== X-Gm-Message-State: AHYfb5gVqsSYOrE2abH5YUgLUAwNMmu+sWLNufcwMZYP55xnlP/D5s22 5GqlIXOHtGnIEusv X-Received: by 10.200.46.161 with SMTP id h30mr17830654qta.202.1502384522011; Thu, 10 Aug 2017 10:02:02 -0700 (PDT) Received: from cm.localdomain (va-67-233-122-109.dhcp.embarqhsd.net. [67.233.122.109]) by smtp.gmail.com with ESMTPSA id s22sm4174653qte.92.2017.08.10.10.02.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Aug 2017 10:02:01 -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 2/2] dma-buf: fix reservation_object_wait_timeout_rcu to wait correctly v2 Date: Thu, 10 Aug 2017 13:01:49 -0400 Message-Id: <1502384509-10465-3-git-send-email-alexander.deucher@amd.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1502384509-10465-1-git-send-email-alexander.deucher@amd.com> References: <1502384509-10465-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 d4881f9..dec3a81 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -431,12 +431,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); @@ -463,22 +476,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)) {