From: Ben Skeggs <bskeggs@nvidia.com>
To: <nouveau@lists.freedesktop.org>
Subject: Re: [PATCH] nouveau/fence: handle cross device fences properly.
Date: Wed, 8 Jan 2025 11:49:03 +1000 [thread overview]
Message-ID: <5ed045e8-020d-4d41-8d18-c29d07c044bf@nvidia.com> (raw)
In-Reply-To: <CAPM=9twK4UUnrOc1rB7bZLgWG534HH14vsdyCgUcKX1YLrnNDg@mail.gmail.com>
On 8/1/25 11:04, Dave Airlie wrote:
> On Wed, 8 Jan 2025 at 02:02, Danilo Krummrich <dakr@kernel.org> wrote:
>> On Tue, Jan 07, 2025 at 03:58:46PM +1000, Dave Airlie wrote:
>>> From: Dave Airlie <airlied@redhat.com>
>>>
>>> If we have two nouveau controlled devices and one passes a dma-fence
>>> to the other, when we hit the sync path it can cause the second device
>>> to try and put a sync wait in it's pushbuf for the seqno of the context
>>> on the first device.
>>>
>>> Since fence contexts are vmm bound, check the if vmm's match between
>>> both users, this should ensure that fence seqnos don't get used wrongly
>>> on incorrect channels.
>> The fence sequence number is global, i.e. per device, hence checking the vmm
>> context seems too restrictive.
>>
>> Wouldn't it be better to ensure that `prev->cli->drm == chan->cli->drm`?
> Can you prove that? I thought the same and I've gone around a few
> times yesterday/today and convinced myself what I wrote is right.
I think Danilo is right. Using the VMM would prevent synchronisation
between clients on the same device, which was one of the intended purposes.
>
> dma_fence_init gets passed the seqno which comes from fctx->sequence,
> which is nouveau_fence_chan, which gets allocated for each channel.
All this code is really old and horrible, especially after not receiving
much attention through many many DRM changes over the years. But - all
channels share the semaphore buffer, each with their own (fixed, based
on channel id) offset. There are indeed per-channel GPU VA mappings of
the buffer in the fctx, but they all point at the same underlying memory.
The "new" exec submission path doesn't use nouveau_fence_sync() at all.
This isn't the worst idea in the world, given various shortcomings in
how it's currently implemented, but I've never felt confident
*something* wouldn't regress by removing its use in the older paths (or
buffer moves).
>
> So we should hit this path if we have 2 userspace submits, one with
> say graphics, the one with copy engine contexts, otherwise we should
> wait on the CPU.
>
>>> drivers/gpu/drm/nouveau/nouveau_fence.c | 3 ++-
>>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
>>> index ee5e9d40c166f..5743c82f4094b 100644
>>> --- a/drivers/gpu/drm/nouveau/nouveau_fence.c
>>> +++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
>>> @@ -370,7 +370,8 @@ nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan,
>>>
>>> rcu_read_lock();
>>> prev = rcu_dereference(f->channel);
>>> - if (prev && (prev == chan ||
>>> + if (prev && (prev->vmm == chan->vmm) &&
>>> + (prev == chan ||
>> Maybe better break it down a bit, e.g.
>>
>> bool local = prev && (prev->... == chan->...);
>>
>> if (local && ...) {
>> ...
>> }
> I'll update that once we resolve the above.
>
> Dave.
next prev parent reply other threads:[~2025-01-08 1:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-07 5:58 [PATCH] nouveau/fence: handle cross device fences properly Dave Airlie
2025-01-07 6:16 ` Ben Skeggs
2025-01-07 16:02 ` Danilo Krummrich
2025-01-08 1:04 ` Dave Airlie
2025-01-08 1:49 ` Ben Skeggs [this message]
2025-01-08 7:39 ` Danilo Krummrich
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=5ed045e8-020d-4d41-8d18-c29d07c044bf@nvidia.com \
--to=bskeggs@nvidia.com \
--cc=nouveau@lists.freedesktop.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.