From: John Hubbard Date: Sat, 15 Nov 2025 01:09:22 +0000 (-0800) Subject: gpu: nova-core: provide a clear error report for unsupported GPUs X-Git-Url: https://gentwo.org/gitweb/?a=commitdiff_plain;h=ce89e3e019f1ec4b11356f35feb8bd8c0f2c6bf7;p=linux%2F.git gpu: nova-core: provide a clear error report for unsupported GPUs Pass in a PCI device to Spec::new(), and provide a Display implementation for boot42, in order to provide a clear, concise report of what happened: the driver read NV_PMC_BOOT42, and found that the GPU is not supported. For very old GPUs (older than Fermi), the driver still returns ENODEV, but it does so without a driver-specific dmesg report. That is exactly appropriate, because if such a GPU is installed, it can only be supported by Nouveau. And if so, the user is not helped by additional error messages from Nova. Here's the full dmesg output for a Blackwell (not yet supported) GPU: NovaCore 0000:01:00.0: Probe Nova Core GPU driver. NovaCore 0000:01:00.0: Unsupported chipset: boot42 = 0x1b2a1000 (architecture 0x1b, implementation 0x2) NovaCore 0000:01:00.0: probe with driver NovaCore failed with error -524 Cc: Alexandre Courbot Cc: Danilo Krummrich Cc: Timur Tabi Cc: Joel Fernandes Signed-off-by: John Hubbard [acourbot@nvidia.com: fix commit log with ENODEV (not ENOTSUPP) error code for unsupported GPUs.] Signed-off-by: Alexandre Courbot Message-ID: <20251115010923.1192144-5-jhubbard@nvidia.com> --- diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs index 3e3375f8fe99..19755af6ad04 100644 --- a/drivers/gpu/nova-core/gpu.rs +++ b/drivers/gpu/nova-core/gpu.rs @@ -182,7 +182,7 @@ pub(crate) struct Spec { } impl Spec { - fn new(bar: &Bar0) -> Result { + fn new(dev: &device::Device, bar: &Bar0) -> Result { // Some brief notes about boot0 and boot42, in chronological order: // // NV04 through NV50: @@ -207,7 +207,10 @@ fn new(bar: &Bar0) -> Result { return Err(ENODEV); } - Spec::try_from(regs::NV_PMC_BOOT_42::read(bar)) + let boot42 = regs::NV_PMC_BOOT_42::read(bar); + Spec::try_from(boot42).inspect_err(|_| { + dev_err!(dev, "Unsupported chipset: {}\n", boot42); + }) } } @@ -259,7 +262,7 @@ pub(crate) fn new<'a>( bar: &'a Bar0, ) -> impl PinInit + 'a { try_pin_init!(Self { - spec: Spec::new(bar).inspect(|spec| { + spec: Spec::new(pdev.as_ref(), bar).inspect(|spec| { dev_info!(pdev.as_ref(),"NVIDIA ({})\n", spec); })?, diff --git a/drivers/gpu/nova-core/regs.rs b/drivers/gpu/nova-core/regs.rs index 60b543ed254a..82cc6c0790e5 100644 --- a/drivers/gpu/nova-core/regs.rs +++ b/drivers/gpu/nova-core/regs.rs @@ -67,6 +67,24 @@ pub(crate) fn chipset(self) -> Result { }) .and_then(Chipset::try_from) } + + /// Returns the raw architecture value from the register. + fn architecture_raw(self) -> u8 { + ((self.0 >> Self::ARCHITECTURE_RANGE.start()) & ((1 << Self::ARCHITECTURE_RANGE.len()) - 1)) + as u8 + } +} + +impl kernel::fmt::Display for NV_PMC_BOOT_42 { + fn fmt(&self, f: &mut kernel::fmt::Formatter<'_>) -> kernel::fmt::Result { + write!( + f, + "boot42 = 0x{:08x} (architecture 0x{:x}, implementation 0x{:x})", + self.0, + self.architecture_raw(), + self.implementation() + ) + } } // PBUS