Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CFB05C433EF for ; Sat, 11 Dec 2021 09:59:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 619E010E6E3; Sat, 11 Dec 2021 09:59:34 +0000 (UTC) Received: from manul.sfritsch.de (manul.sfritsch.de [IPv6:2a01:4f8:172:195f:112::2]) by gabe.freedesktop.org (Postfix) with ESMTPS id 72C5210E6E3; Sat, 11 Dec 2021 09:59:33 +0000 (UTC) Message-ID: Date: Sat, 11 Dec 2021 10:59:23 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH] drm/nouveau: wait for the exclusive fence after the shared ones v2 Content-Language: de-DE To: =?UTF-8?Q?Christian_K=c3=b6nig?= , dmoulding@me.com, bskeggs@redhat.com References: <20211209102335.18321-1-christian.koenig@amd.com> From: Stefan Fritsch In-Reply-To: <20211209102335.18321-1-christian.koenig@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On 09.12.21 11:23, Christian König wrote: > Always waiting for the exclusive fence resulted on some performance > regressions. So try to wait for the shared fences first, then the > exclusive fence should always be signaled already. > > v2: fix incorrectly placed "(", add some comment why we do this. > > Signed-off-by: Christian König Tested-by: Stefan Fritsch Please also add a cc for linux-stable, so that this is fixed in 5.15.x Cheers, Stefan > --- > drivers/gpu/drm/nouveau/nouveau_fence.c | 28 +++++++++++++------------ > 1 file changed, 15 insertions(+), 13 deletions(-) > > diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c > index 05d0b3eb3690..0ae416aa76dc 100644 > --- a/drivers/gpu/drm/nouveau/nouveau_fence.c > +++ b/drivers/gpu/drm/nouveau/nouveau_fence.c > @@ -353,15 +353,22 @@ nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool e > > if (ret) > return ret; > - } > > - fobj = dma_resv_shared_list(resv); > - fence = dma_resv_excl_fence(resv); > + fobj = NULL; > + } else { > + fobj = dma_resv_shared_list(resv); > + } > > - if (fence) { > + /* Waiting for the exclusive fence first causes performance regressions > + * under some circumstances. So manually wait for the shared ones first. > + */ > + for (i = 0; i < (fobj ? fobj->shared_count : 0) && !ret; ++i) { > struct nouveau_channel *prev = NULL; > bool must_wait = true; > > + fence = rcu_dereference_protected(fobj->shared[i], > + dma_resv_held(resv)); > + > f = nouveau_local_fence(fence, chan->drm); > if (f) { > rcu_read_lock(); > @@ -373,20 +380,13 @@ nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool e > > if (must_wait) > ret = dma_fence_wait(fence, intr); > - > - return ret; > } > > - if (!exclusive || !fobj) > - return ret; > - > - for (i = 0; i < fobj->shared_count && !ret; ++i) { > + fence = dma_resv_excl_fence(resv); > + if (fence) { > struct nouveau_channel *prev = NULL; > bool must_wait = true; > > - fence = rcu_dereference_protected(fobj->shared[i], > - dma_resv_held(resv)); > - > f = nouveau_local_fence(fence, chan->drm); > if (f) { > rcu_read_lock(); > @@ -398,6 +398,8 @@ nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool e > > if (must_wait) > ret = dma_fence_wait(fence, intr); > + > + return ret; > } > > return ret;