From: Danilo Krummrich <dakr@kernel.org>
To: "Christian König" <christian.koenig@amd.com>
Cc: Philipp Stanner <phasta@kernel.org>,
Lyude Paul <lyude@redhat.com>, David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
Sumit Semwal <sumit.semwal@linaro.org>,
dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
linaro-mm-sig@lists.linaro.org, stable@vger.kernel.org
Subject: Re: [PATCH v2] drm/nouveau: Prevent signalled fences in pending list
Date: Thu, 3 Apr 2025 14:31:02 +0200 [thread overview]
Message-ID: <Z-5_hh8kPv8btF6k@pollux> (raw)
In-Reply-To: <c779bc2f-06af-4278-8bb5-08afc074b580@amd.com>
On Thu, Apr 03, 2025 at 02:08:06PM +0200, Christian König wrote:
> Am 03.04.25 um 12:13 schrieb Philipp Stanner:
>
> > @@ -235,6 +227,19 @@ nouveau_fence_emit(struct nouveau_fence *fence)
> > &fctx->lock, fctx->context, ++fctx->sequence);
> > kref_get(&fctx->fence_ref);
> >
> > + fence->cb.func = nouveau_fence_cleanup_cb;
> > + /* Adding a callback runs into __dma_fence_enable_signaling(), which will
> > + * ultimately run into nouveau_fence_no_signaling(), where a WARN_ON
> > + * would fire because the refcount can be dropped there.
> > + *
> > + * Increment the refcount here temporarily to work around that.
> > + */
> > + dma_fence_get(&fence->base);
> > + ret = dma_fence_add_callback(&fence->base, &fence->cb, nouveau_fence_cleanup_cb);
>
> That looks like a really really awkward approach. The driver basically uses a the DMA fence infrastructure as middle layer and callbacks into itself to cleanup it's own structures.
>
> Additional to that we don't guarantee any callback order for the DMA fence and so it can be that mix cleaning up the callback with other work which is certainly not good when you want to guarantee that the cleanup happens under the same lock.
>
> Instead the call to dma_fence_signal_locked() should probably be removed from nouveau_fence_signal() and into nouveau_fence_context_kill() and nouveau_fence_update().
>
> This way nouveau_fence_is_signaled() can call this function as well.
Yes, I think this would work as well. It wouldn't work if only
dma_fence_signal() is called on this fence, but that should be fine.
So, I agree that's probably the better approach.
> BTW: nouveau_fence_no_signaling() looks completely broken as well. It calls nouveau_fence_is_signaled() and then list_del() on the fence head.
It does indeed look broken, as in the fence may not be signaled at all. If at
all, it should call dma_fence_is_signaled() instead.
> As far as I can see that is completely superfluous and should probably be dropped. IIRC I once had a patch to clean that up but it was dropped for some reason.
Agreed, to me it looks unnecessary as well.
next prev parent reply other threads:[~2025-04-03 12:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-03 10:13 [PATCH v2] drm/nouveau: Prevent signalled fences in pending list Philipp Stanner
2025-04-03 10:17 ` Philipp Stanner
2025-04-03 10:25 ` Danilo Krummrich
2025-04-03 12:22 ` Christian König
2025-04-03 12:41 ` Danilo Krummrich
2025-04-03 12:08 ` Christian König
2025-04-03 12:31 ` Danilo Krummrich [this message]
2025-04-03 12:58 ` Philipp Stanner
2025-04-03 13:15 ` Danilo Krummrich
2025-04-03 13:20 ` Christian König
[not found] ` <72156b6a-9a8b-4485-8091-95f02c96eba8@amd.com>
2025-04-03 14:40 ` Philipp Stanner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z-5_hh8kPv8btF6k@pollux \
--to=dakr@kernel.org \
--cc=airlied@gmail.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=lyude@redhat.com \
--cc=nouveau@lists.freedesktop.org \
--cc=phasta@kernel.org \
--cc=simona@ffwll.ch \
--cc=stable@vger.kernel.org \
--cc=sumit.semwal@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox