From: sashiko-bot@kernel.org
To: "Lyude Paul" <lyude@redhat.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 1/5] drm/nouveau/gsp/r535: Add support for INTERNAL_GCX_ENTRY_PREREQUISITE
Date: Tue, 15 Sep 2026 21:17:27 +0000 [thread overview]
Message-ID: <20260915211727.9409E1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260915210647.695187-2-lyude@redhat.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] nouveau: nvif_device_gcx_ready negative error codes handled as bitmask
--
commit 181d7ad17939e59149b939f631f63cac7294478a
Author: Lyude Paul <lyude@redhat.com>
drm/nouveau/gsp/r535: Add support for INTERNAL_GCX_ENTRY_PREREQUISITE
This commit adds support for querying the GSP to see if the GPU is ready
to enter Gc6 and/or GcOff before runtime suspending. If the GPU is not
ready, the runtime suspend process is delayed.
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
[ ... ]
> @@ -1164,6 +1165,14 @@ nouveau_pmops_runtime_suspend(struct device *dev)
> return -EBUSY;
> }
>
> + /* Check if the GPU itself is ready for runtime suspend, otherwise mark as busy and check
> + * again in a bit. */
> + if (!(nvif_device_gcx_ready(nvif) & NV_DEVICE_GCOFF_READY)) {
> + NV_DEBUG(drm, "GPU isn't ready for suspend yet, delaying...\n");
> + pm_runtime_mark_last_busy(dev);
> + return -EBUSY;
> + }
> +
[Severity: Medium]
Should this check for a negative error code before applying the bitmask?
The nvif_device_gcx_ready() function can return negative error codes
if the underlying RPC call fails. Because this returned integer is
directly bitwise ANDed with NV_DEVICE_GCOFF_READY (which is BIT(1)),
the two's complement representation of a negative error code will yield
an arbitrary true or false result depending on its specific bit pattern.
For example, if an error returns -EINVAL (-22), bit 1 is set. The bitwise
check evaluates to true, which bypasses the delay and unsafely puts the
GPU to sleep. Alternatively, if the error is -ENOMEM (-12), bit 1 is
cleared, which evaluates to false and delays the suspend.
> diff --git a/drivers/gpu/drm/nouveau/nvif/device.c b/drivers/gpu/drm/nouveau/nvif/device.c
> --- a/drivers/gpu/drm/nouveau/nvif/device.c
> +++ b/drivers/gpu/drm/nouveau/nvif/device.c
[ ... ]
> +int
> +nvif_device_gcx_ready(struct nvif_device *device)
> +{
> + struct nv_device_gcx_ready_v0 args = {};
> + int ret;
> +
> + ret = nvif_object_mthd(&device->object, NV_DEVICE_V0_GCX_READY, &args, sizeof(args));
> + if (ret)
> + return ret;
> +
> + return args.ready;
> +}
Here is where nvif_device_gcx_ready() explicitly propagates the negative
error code returned from nvif_object_mthd() on failure.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260915210647.695187-1-lyude@redhat.com?part=1
next prev parent reply other threads:[~2026-09-15 21:17 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 18:51 [PATCH v2 0/5] drm/nouveau/gsp/r570: Follow OpenRM's runtime PM process more closely Lyude Paul
2026-09-15 18:51 ` Lyude Paul
2026-09-15 18:51 ` [PATCH v2 1/5] drm/nouveau/gsp/r535: Add support for INTERNAL_GCX_ENTRY_PREREQUISITE Lyude Paul
2026-09-15 18:51 ` Lyude Paul
2026-09-15 21:17 ` sashiko-bot [this message]
2026-09-15 18:51 ` [PATCH v2 2/5] drm/nouveau/gsp/r535: Add support for MEMSYS_GET_STATIC_CONFIG Lyude Paul
2026-09-15 18:51 ` Lyude Paul
2026-09-15 21:17 ` sashiko-bot
2026-09-15 18:51 ` [PATCH v2 3/5] drm/nouveau/gsp/r570: Add comp mode workaround from issue #3172217 Lyude Paul
2026-09-15 18:51 ` Lyude Paul
2026-09-15 21:21 ` sashiko-bot
2026-09-15 18:51 ` [PATCH v2 4/5] drm/nouveau/gsp/r570: Start saving comptag backing stores Lyude Paul
2026-09-15 18:51 ` Lyude Paul
2026-09-15 21:20 ` sashiko-bot
2026-09-15 18:51 ` [PATCH v2 5/5] drm/nouveau/gsp/r570: Enable Gcoff in fbsr again Lyude Paul
2026-09-15 18:51 ` Lyude Paul
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=20260915211727.9409E1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=lyude@redhat.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 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.