Skip to content

Commit ce89e3e

Browse files
johnhubbardGnurou
authored andcommitted
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 <acourbot@nvidia.com> Cc: Danilo Krummrich <dakr@kernel.org> Cc: Timur Tabi <ttabi@nvidia.com> Cc: Joel Fernandes <joelagnelf@nvidia.com> Signed-off-by: John Hubbard <jhubbard@nvidia.com> [acourbot@nvidia.com: fix commit log with ENODEV (not ENOTSUPP) error code for unsupported GPUs.] Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Message-ID: <20251115010923.1192144-5-jhubbard@nvidia.com>
1 parent 0ecc08e commit ce89e3e

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

drivers/gpu/nova-core/gpu.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ pub(crate) struct Spec {
182182
}
183183

184184
impl Spec {
185-
fn new(bar: &Bar0) -> Result<Spec> {
185+
fn new(dev: &device::Device, bar: &Bar0) -> Result<Spec> {
186186
// Some brief notes about boot0 and boot42, in chronological order:
187187
//
188188
// NV04 through NV50:
@@ -207,7 +207,10 @@ impl Spec {
207207
return Err(ENODEV);
208208
}
209209

210-
Spec::try_from(regs::NV_PMC_BOOT_42::read(bar))
210+
let boot42 = regs::NV_PMC_BOOT_42::read(bar);
211+
Spec::try_from(boot42).inspect_err(|_| {
212+
dev_err!(dev, "Unsupported chipset: {}\n", boot42);
213+
})
211214
}
212215
}
213216

@@ -259,7 +262,7 @@ impl Gpu {
259262
bar: &'a Bar0,
260263
) -> impl PinInit<Self, Error> + 'a {
261264
try_pin_init!(Self {
262-
spec: Spec::new(bar).inspect(|spec| {
265+
spec: Spec::new(pdev.as_ref(), bar).inspect(|spec| {
263266
dev_info!(pdev.as_ref(),"NVIDIA ({})\n", spec);
264267
})?,
265268

drivers/gpu/nova-core/regs.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,24 @@ impl NV_PMC_BOOT_42 {
6767
})
6868
.and_then(Chipset::try_from)
6969
}
70+
71+
/// Returns the raw architecture value from the register.
72+
fn architecture_raw(self) -> u8 {
73+
((self.0 >> Self::ARCHITECTURE_RANGE.start()) & ((1 << Self::ARCHITECTURE_RANGE.len()) - 1))
74+
as u8
75+
}
76+
}
77+
78+
impl kernel::fmt::Display for NV_PMC_BOOT_42 {
79+
fn fmt(&self, f: &mut kernel::fmt::Formatter<'_>) -> kernel::fmt::Result {
80+
write!(
81+
f,
82+
"boot42 = 0x{:08x} (architecture 0x{:x}, implementation 0x{:x})",
83+
self.0,
84+
self.architecture_raw(),
85+
self.implementation()
86+
)
87+
}
7088
}
7189

7290
// PBUS

0 commit comments

Comments
 (0)