dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Marek Czernohous" <mczernohous@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v4 3/3] drm/nouveau: subscribe to channel-kill events on NV50 and newer
Date: Fri, 21 Aug 2026 15:33:49 +0000	[thread overview]
Message-ID: <20260821153349.ACF961F000E9@smtp.kernel.org> (raw)
In-Reply-To: <178732578167.167481.2178147998794444181@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] `chan->fence` is published without memory barriers before its fields and spinlock are fully initialized, exposing an uninitialized spinlock to the concurrent channel kill event handler.
--

--- Patch [3]: [PATCH v4 3/3] drm/nouveau: subscribe to channel-kill events on NV50 and newer ---
commit 526eef3958eedb0aae06aba1612c73d287cde11e
Author: Marek Czernohous <mczernohous@gmail.com>

drm/nouveau: subscribe to channel-kill events on NV50 and newer

This commit lowers the class gate for subscribing to channel-killed events
from FERMI_CHANNEL_GPFIFO to NV50_CHANNEL_GPFIFO. This enables NV50 and Tesla
to correctly receive channel error notifications and signal pending fences.

> diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
> index 605ce74c0d155..54e2202cb852f 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_chan.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
> @@ -378,7 +378,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
>  	if (ret)
>  		return ret;
>  
> -	if (chan->user.oclass >= FERMI_CHANNEL_GPFIFO) {
> +	if (chan->user.oclass >= NV50_CHANNEL_GPFIFO) {
>  		DEFINE_RAW_FLEX(struct nvif_event_v0, args, data,
>  				sizeof(struct nvif_chan_event_v0));
>  		struct nvif_chan_event_v0 *host =

[Severity: High]
This is a pre-existing issue, but this change exposes an existing race condition
to NV50.

By allowing the channel kill event in this block, the event can fire before the
fence context is fully initialized later in nouveau_channel_init():

drivers/gpu/drm/nouveau/nouveau_chan.c:nouveau_channel_init() {
	...
	if (chan->user.oclass >= NV50_CHANNEL_GPFIFO) {
		...
		ret = nvif_event_allow(&chan->kill);
	}
	...
	ret = nouveau_fence(drm)->context_new(chan);
}

In nv84_fence_context_new() (and similarly in nv50_fence_context_new()), the
fence pointer is published without a memory barrier:

	fctx = chan->fence = kzalloc_obj(*fctx);

If a channel fault occurs and the kill event handler runs concurrently:

drivers/gpu/drm/nouveau/nouveau_chan.c:nouveau_channel_kill() {
	...
	if (fctx && smp_load_acquire(&fctx->ready))
		nouveau_fence_context_kill(fctx, -ENODEV);
}

Because chan->fence was published without a store release, can
smp_load_acquire() observe non-NULL for fctx but read stale, uninitialized
memory for fctx->ready?

If the stale memory evaluates to true, it would proceed to call
nouveau_fence_context_kill(), which acquires an uninitialized spinlock:

drivers/gpu/drm/nouveau/nouveau_fence.c:nouveau_fence_context_kill() {
	...
	spin_lock_irqsave(&fctx->lock, flags);
}

Could this lead to a kernel crash or deadlock?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/178732578167.167481.5619512544301226563@gmail.com?part=3

  reply	other threads:[~2026-08-21 15:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21 15:23 [PATCH v4 0/3] drm/nouveau: channel-kill event ordering fixes, and lower the gate to NV50 Marek Czernohous
2026-08-21 15:23 ` [PATCH v4 3/3] drm/nouveau: subscribe to channel-kill events on NV50 and newer Marek Czernohous
2026-08-21 15:33   ` sashiko-bot [this message]
2026-08-21 15:23 ` [PATCH v4 1/3] drm/nouveau: unsubscribe the channel-kill event before the fence context Marek Czernohous
2026-08-21 15:35   ` sashiko-bot
2026-08-21 15:23 ` [PATCH v4 2/3] drm/nouveau: don't kill a fence context that is not ready yet Marek Czernohous
2026-08-21 15:35   ` sashiko-bot

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=20260821153349.ACF961F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mczernohous@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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