Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1932150pxb; Thu, 16 Sep 2021 20:44:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnR/65x6wqYM+C4J/6HqvPdYUWoVnn12EMaetgZApg73HGC5brJujNpJiN6WuGVJccGpPH X-Received: by 2002:a5d:9145:: with SMTP id y5mr6828066ioq.200.1631850244578; Thu, 16 Sep 2021 20:44:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631850244; cv=none; d=google.com; s=arc-20160816; b=uQC51lC7BRUXYVJeSjFi5MzCvge1SEdG4jxfMz3u/v9+VvLZ7qDUKU+39ik/LdUUpg AJiDxurBdPrITseJQ37JL1K2mT5yB2pSB3K7OPEiV+UdoOHWVhfLecRSFCSxABtDUhSB 4q6J22wjaKGGUoooZYkeiV2A+9i7aBZD9T5UHukfOclYAwrxNu6GgqEEMO6+72U/ng80 BFea3nzoz7Dj0n93Gjn2YIWaD3IkxfEuo2v2TUI+bHvoPG0QFaCTaJyIW2TP+xpHcCVh 0q20IEoGSMMQInwaiKWydQgtRyBDTqoBj6AcmA7B9aTA2hyGtPSR1SCqnczlcQ4ZQygP ACQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+aPXkwP1ppFRWDlbLtcW8cMCDXYcFZCzwg3QIDuLv7o=; b=cAmjqInNL4vssDM19M2PF34tCg6QP53/TGEOGZJo0CayDcwZb7nv6LIFYbeKDnVjeR vTWhCcMGL8eSc0CWlt7tccEnZ2oVbtvbJ3agfP5nGiIhJtwA5LT6UffnXjoEbjCPS+uM dJeqg/aMLoH3ZPe0vwTX1JPk02wAKI7ffmi86nuYA0NWdZekweuvjVb2NzslweNTKyv+ gmF261d+XKGZDCDrd2I6tA/hShQC5b3oVyQ16vih+OyHLwjHXCcQz1psKC5GNgQKpF4x NrEyI7PVuImeCsqZe6+eCmQNB/NWIBY4Cz4A8gsD3IFfk5VYxytxeR48Ucgz85+CcLa9 Xkzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mHd5qTGe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m10si5557547ilu.53.2021.09.16.20.43.49; Thu, 16 Sep 2021 20:44:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mHd5qTGe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347529AbhIPRcC (ORCPT + 99 others); Thu, 16 Sep 2021 13:32:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:44128 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236705AbhIPRWi (ORCPT ); Thu, 16 Sep 2021 13:22:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8DAD061356; Thu, 16 Sep 2021 16:43:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810592; bh=sQlpCIQOIZc/1gWnMmczeaTUI9JHZ8cwU8Uv5hxetBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mHd5qTGeBYBkkns/Va562UnUjR6u5gTECXP6PmbW3T2YiiMcjmSp3M8bgzv7I1FgI rOdkzLUoWvwUEVoC1W3B984UcZhJICJZg/N7rTJyv5tL564ml+vurtFZpL7in0+99I md7a9kj2uayQB+u1ktQ61juJl6xWEW5R191gZHgQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Christian=20K=C3=B6nig?= , Daniel Vetter , Sasha Levin Subject: [PATCH 5.14 165/432] dma-buf: fix dma_resv_test_signaled test_all handling v2 Date: Thu, 16 Sep 2021 17:58:34 +0200 Message-Id: <20210916155816.339127096@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christian König [ Upstream commit 9d38814d1e346ea37a51cbf31f4424c9d059459e ] As the name implies if testing all fences is requested we should indeed test all fences and not skip the exclusive one because we see shared ones. v2: fix logic once more Signed-off-by: Christian König Reviewed-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20210702111642.17259-3-christian.koenig@amd.com Signed-off-by: Sasha Levin --- drivers/dma-buf/dma-resv.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index f26c71747d43..e744fd87c63c 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -615,25 +615,21 @@ static inline int dma_resv_test_signaled_single(struct dma_fence *passed_fence) */ bool dma_resv_test_signaled(struct dma_resv *obj, bool test_all) { - unsigned int seq, shared_count; + struct dma_fence *fence; + unsigned int seq; int ret; rcu_read_lock(); retry: ret = true; - shared_count = 0; seq = read_seqcount_begin(&obj->seq); if (test_all) { struct dma_resv_list *fobj = dma_resv_shared_list(obj); - unsigned int i; - - if (fobj) - shared_count = fobj->shared_count; + unsigned int i, shared_count; + shared_count = fobj ? fobj->shared_count : 0; for (i = 0; i < shared_count; ++i) { - struct dma_fence *fence; - fence = rcu_dereference(fobj->shared[i]); ret = dma_resv_test_signaled_single(fence); if (ret < 0) @@ -641,24 +637,19 @@ bool dma_resv_test_signaled(struct dma_resv *obj, bool test_all) else if (!ret) break; } - - if (read_seqcount_retry(&obj->seq, seq)) - goto retry; } - if (!shared_count) { - struct dma_fence *fence_excl = dma_resv_excl_fence(obj); - - if (fence_excl) { - ret = dma_resv_test_signaled_single(fence_excl); - if (ret < 0) - goto retry; + fence = dma_resv_excl_fence(obj); + if (ret && fence) { + ret = dma_resv_test_signaled_single(fence); + if (ret < 0) + goto retry; - if (read_seqcount_retry(&obj->seq, seq)) - goto retry; - } } + if (read_seqcount_retry(&obj->seq, seq)) + goto retry; + rcu_read_unlock(); return ret; } -- 2.30.2