From 52deb6825ca441a7cddf9d025cabb66e4f47f8f6 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 29 Nov 2023 13:57:11 +1000 Subject: simple print out some info about gpu --- drivers/gpu/drm/nova/nova_drv.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/gpu/drm/nova/nova_drv.rs b/drivers/gpu/drm/nova/nova_drv.rs index 9eeb69cb7e3e..510692ea43d7 100644 --- a/drivers/gpu/drm/nova/nova_drv.rs +++ b/drivers/gpu/drm/nova/nova_drv.rs @@ -37,6 +37,29 @@ impl pci::Driver for NovaDevice { fn probe(_dev: &mut pci::Device, _id_info: Option<&Self::IdInfo>) -> Result { pr_info!("probe()\n"); + _dev.enable_device_mem()?; + _dev.set_master(); + + let bars = _dev.select_bars(bindings::IORESOURCE_MEM.into()); + + let res = _dev.take_resource(0).ok_or(ENXIO)?; + let bar = unsafe { IoMem::<16777216>::try_new(res) }?; + + let boot0 = u64::from_le(bar.readq(0)); + + if (boot0 & 0x1f000000) == 0 { + return Err(ENODEV); + } + pr_info!("nvidia hw rev 0x{:#x}", boot0); + let chipset = (boot0 & 0x1ff00000) >> 20; + let chiprev = (boot0 & 0xff); + + match (chipset & 0x1f0) { + 0x160 => pr_info!("TU100"), + 0x170 => pr_info!("GA100"), + 0x190 => pr_info!("AD100"), + _ => return Err(ENODEV) + } Ok(()) } -- cgit v1.2.3-58-ga151