public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: John Hubbard <jhubbard@nvidia.com>
To: Eliot Courtney <ecourtney@nvidia.com>,
	Danilo Krummrich <dakr@kernel.org>,
	Alice Ryhl <aliceryhl@google.com>,
	Alexandre Courbot <acourbot@nvidia.com>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Cc: Alistair Popple <apopple@nvidia.com>,
	Joel Fernandes <joelagnelf@nvidia.com>,
	Timur Tabi <ttabi@nvidia.com>,
	rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/9] gpu: nova-core: gsp: add NV_STATUS error code bindings
Date: Sun, 5 Apr 2026 12:55:47 -0700	[thread overview]
Message-ID: <fd010f7a-6d0d-4faf-bdea-23bac608f03e@nvidia.com> (raw)
In-Reply-To: <20260325-rmcontrol-v3-1-f3101093484e@nvidia.com>

On 3/25/26 5:13 AM, Eliot Courtney wrote:
> Add bindgen generated constants for NV_STATUS. This is used for RM
> control messages.
> 
> Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
> ---
>   drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs | 144 ++++++++++++++++++++++
>   1 file changed, 144 insertions(+)
> 
> diff --git a/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs b/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs
> index 334e8be5fde8..dd37a7fd58c6 100644
> --- a/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs
> +++ b/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs
> @@ -379,6 +379,150 @@ pub struct NV2080_CTRL_CMD_FB_GET_FB_REGION_INFO_PARAMS {
>       pub __bindgen_padding_0: [u8; 4usize],
>       pub fbRegion: [NV2080_CTRL_CMD_FB_GET_FB_REGION_FB_REGION_INFO; 16usize],
>   }
> +pub const NV_OK: _bindgen_ty_4 = 0;
> +pub const NV_ERR_GENERIC: _bindgen_ty_4 = 65535;
...
> +pub const NV_ERR_RESOURCE_RETIREMENT_ERROR: _bindgen_ty_4 = 134;
> +pub const NV_WARN_HOT_SWITCH: _bindgen_ty_4 = 65537;
> +pub const NV_WARN_INCORRECT_PERFMON_DATA: _bindgen_ty_4 = 65538;

If we go with pulling these ERR_ and WARN_ items in directly
from GSP-RM, then we should also update Alistair's bindgen
helper, or my fork of it:

     https://github.com/apopple-nvidia/nova-gsp-binding-generator/commits/main/
     https://github.com/johnhubbard/nova-gsp-binding-generator/commits/main

However, the deeper problem is that the C headers define these as
#defines, so bindgen emits pub const u32 items. The hand-written
NvStatus enum in patch 2 has no compile-time relationship to them. When
Open RM adds a new code, the Rust enum silently absorbs it into
Unknown(u32) -> Err(EIO) with no compiler diagnostic.

Which brings us back to a feature that Alex Courbot and Danilo have been
asking for, and I've been treating as "nice to have, maybe next month"
for apparently too long. And that is, generating Rust bindings directly
from the GSP-RM build system.

I think it's time, yes?

> +pub const NV_WARN_MISMATCHED_SLAVE: _bindgen_ty_4 = 65539;
> +pub const NV_WARN_MISMATCHED_TARGET: _bindgen_ty_4 = 65540;
> +pub const NV_WARN_MORE_PROCESSING_REQUIRED: _bindgen_ty_4 = 65541;
> +pub const NV_WARN_NOTHING_TO_DO: _bindgen_ty_4 = 65542;
> +pub const NV_WARN_NULL_OBJECT: _bindgen_ty_4 = 65543;
> +pub const NV_WARN_OUT_OF_RANGE: _bindgen_ty_4 = 65544;
> +pub type _bindgen_ty_4 = ffi::c_uint;
>   #[repr(C)]
>   #[derive(Debug, Copy, Clone, MaybeZeroable)]
>   pub struct NV2080_CTRL_GPU_GET_GID_INFO_PARAMS {
> 

thanks,
-- 
John Hubbard


  reply	other threads:[~2026-04-05 19:55 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-25 12:13 [PATCH v3 0/9] gpu: nova-core: gsp: add RM control command infrastructure Eliot Courtney
2026-03-25 12:13 ` [PATCH v3 1/9] gpu: nova-core: gsp: add NV_STATUS error code bindings Eliot Courtney
2026-04-05 19:55   ` John Hubbard [this message]
2026-04-06  8:54     ` Eliot Courtney
2026-04-06 19:05       ` John Hubbard
2026-03-25 12:13 ` [PATCH v3 2/9] gpu: nova-core: gsp: add NvStatus enum for RM control errors Eliot Courtney
2026-04-05 20:05   ` John Hubbard
2026-04-06 12:09     ` Eliot Courtney
2026-04-06 19:02       ` John Hubbard
2026-03-25 12:13 ` [PATCH v3 3/9] gpu: nova-core: gsp: expose GSP-RM internal client and subdevice handles Eliot Courtney
2026-03-25 12:13 ` [PATCH v3 4/9] gpu: nova-core: gsp: add RM control RPC structure binding Eliot Courtney
2026-03-25 12:13 ` [PATCH v3 5/9] gpu: nova-core: gsp: add types for RM control RPCs Eliot Courtney
2026-03-25 12:13 ` [PATCH v3 6/9] gpu: nova-core: use KVVec for SBufferIter flush Eliot Courtney
2026-03-25 12:13 ` [PATCH v3 7/9] gpu: nova-core: gsp: add RM control command infrastructure Eliot Courtney
2026-03-25 12:13 ` [PATCH v3 8/9] gpu: nova-core: gsp: add CE fault method buffer size bindings Eliot Courtney
2026-03-25 12:13 ` [PATCH v3 9/9] gpu: nova-core: gsp: add FaultMethodBufferSize RM control command Eliot Courtney
2026-04-05 20:12   ` John Hubbard
2026-04-06  2:30     ` Eliot Courtney
2026-04-05 19:48 ` [PATCH v3 0/9] gpu: nova-core: gsp: add RM control command infrastructure John Hubbard
2026-04-06  2:29   ` Eliot Courtney

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=fd010f7a-6d0d-4faf-bdea-23bac608f03e@nvidia.com \
    --to=jhubbard@nvidia.com \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=apopple@nvidia.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ecourtney@nvidia.com \
    --cc=joelagnelf@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=ttabi@nvidia.com \
    /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