From: Danilo Krummrich <dakr@kernel.org>
To: phasta@kernel.org
Cc: "Lyude Paul" <lyude@redhat.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Christian König" <christian.koenig@amd.com>,
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 12:25:47 +0200 [thread overview]
Message-ID: <Z-5iK-mIYPIhanX-@pollux> (raw)
In-Reply-To: <84b0db2de7a26aab00778bcaca15a0dffaa9c32a.camel@mailbox.org>
On Thu, Apr 03, 2025 at 12:17:29PM +0200, Philipp Stanner wrote:
> On Thu, 2025-04-03 at 12:13 +0200, Philipp Stanner wrote:
> > -static int
> > -nouveau_fence_signal(struct nouveau_fence *fence)
> > +static void
> > +nouveau_fence_cleanup_cb(struct dma_fence *dfence, struct
> > dma_fence_cb *cb)
> > {
> > - int drop = 0;
> > + struct nouveau_fence_chan *fctx;
> > + struct nouveau_fence *fence;
> > +
> > + fence = container_of(dfence, struct nouveau_fence, base);
> > + fctx = nouveau_fctx(fence);
> >
> > - dma_fence_signal_locked(&fence->base);
> > list_del(&fence->head);
> > rcu_assign_pointer(fence->channel, NULL);
> >
> > if (test_bit(DMA_FENCE_FLAG_USER_BITS, &fence->base.flags))
> > {
> > - struct nouveau_fence_chan *fctx =
> > nouveau_fctx(fence);
> > -
> > if (!--fctx->notify_ref)
> > - drop = 1;
> > + nvif_event_block(&fctx->event);
> > }
> >
> > dma_fence_put(&fence->base);
>
> What I realized while coding this v2 is that we might want to think
> about whether we really want the dma_fence_put() in the fence callback?
>
> It should work fine, since it's exactly identical to the previous
> code's behavior – but effectively it means that the driver's reference
> will be dropped whenever it signals that fence.
Not quite, it's the reference of the fence context's pending list.
When the fence is emitted, dma_fence_init() is called, which initializes the
reference count to 1. Subsequently, another reference is taken, when the fence
is added to the pending list. Once the fence is signaled and hence removed from
the pending list, we can (and have to) drop this reference.
next prev parent reply other threads:[~2025-04-03 10:25 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 [this message]
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
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-5iK-mIYPIhanX-@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