[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9a8f8500-aa1e-4145-b84d-7ce424ead644@kernel.org>
Date: Tue, 6 Jan 2026 23:44:17 +0100
From: Danilo Krummrich <dakr@...nel.org>
To: John Hubbard <jhubbard@...dia.com>
Cc: Alexandre Courbot <acourbot@...dia.com>,
Joel Fernandes <joelagnelf@...dia.com>, Timur Tabi <ttabi@...dia.com>,
Alistair Popple <apopple@...dia.com>, Edwin Peer <epeer@...dia.com>,
Zhi Wang <zhiw@...dia.com>, David Airlie <airlied@...il.com>,
Simona Vetter <simona@...ll.ch>, Bjorn Helgaas <bhelgaas@...gle.com>,
Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>, Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
nouveau@...ts.freedesktop.org, rust-for-linux@...r.kernel.org,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] gpu: nova-core: use CStr::from_bytes_until_nul() and
remove util.rs
On 1/6/26 11:09 PM, John Hubbard wrote:
> Yes, so that would look approximately like this, I can send this as
> another patch if it looks reasonable:
Thanks, looks good! Two comments below.
> diff --git a/drivers/gpu/nova-core/gsp/boot.rs b/drivers/gpu/nova-core/gsp/boot.rs
> index a53d80620468..71fca7350b94 100644
> --- a/drivers/gpu/nova-core/gsp/boot.rs
> +++ b/drivers/gpu/nova-core/gsp/boot.rs
> @@ -238,11 +238,11 @@ pub(crate) fn boot(
>
> // Obtain and display basic GPU information.
> let info = commands::get_gsp_info(&mut self.cmdq, bar)?;
> - dev_info!(
> - pdev.as_ref(),
> - "GPU name: {}\n",
> - info.gpu_name().unwrap_or("invalid GPU name")
> - );
> + let gpu_name = info
> + .gpu_name()
> + .inspect_err(|e| dev_warn!(pdev.as_ref(), "GPU name: {}\n", e))
> + .unwrap_or("<unavailable>");
> + dev_info!(pdev.as_ref(), "GPU name: {}\n", gpu_name);
I'd probably only print one or the other. Also, I think this should be
dev_dbg!() instead of dev_info!().
> +/// Error type for [`GetGspStaticInfoReply::gpu_name`].
> +#[derive(Debug)]
> +pub(crate) enum GpuNameError {
> + /// The GPU name string does not contain a null terminator.
> + NoNullTerminator(FromBytesUntilNulError),
> +
> + /// The GPU name string contains invalid UTF-8.
> + InvalidUtf8(Utf8Error),
> +}
> +
> +impl kernel::fmt::Display for GpuNameError {
> + fn fmt(&self, f: &mut kernel::fmt::Formatter<'_>) -> kernel::fmt::Result {
> + match self {
> + Self::NoNullTerminator(_) => write!(f, "no null terminator"),
> + Self::InvalidUtf8(e) => write!(f, "invalid UTF-8 at byte {}", e.valid_up_to()),
> + }
> + }
> +}
Do we need this Display impl, or is the derive(Debug) you have already good
enough for the warning print?
Powered by blists - more mailing lists