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?