This commit is contained in:
Ilya Zlobintsev 2025-01-04 15:37:40 +02:00
parent e63e168afb
commit 086ddae1bc
3 changed files with 11 additions and 4 deletions

View File

@ -55,6 +55,7 @@ pub struct AmdGpuController {
} }
impl AmdGpuController { impl AmdGpuController {
#[allow(unused_variables)]
pub fn new_from_path( pub fn new_from_path(
common: CommonControllerInfo, common: CommonControllerInfo,
libdrm_amdgpu: Option<&LibDrmAmdgpu>, libdrm_amdgpu: Option<&LibDrmAmdgpu>,

View File

@ -110,17 +110,17 @@ pub(crate) fn init_controller(
}) })
.unwrap_or_default(); .unwrap_or_default();
let vendor_entry = pci_db.vendors.get_key_value(vendor_id); let vendor = pci_db.vendors.get(&vendor_id.to_ascii_lowercase());
let pci_info = GpuPciInfo { let pci_info = GpuPciInfo {
device_pci_info: PciInfo { device_pci_info: PciInfo {
vendor_id: vendor_id.to_owned(), vendor_id: vendor_id.to_owned(),
vendor: vendor_entry.map(|(vendor_name, _)| vendor_name.clone()), vendor: vendor.map(|vendor| vendor.name.clone()),
model_id: device_id.to_owned(), model_id: device_id.to_owned(),
model: vendor_entry.and_then(|(_, vendor)| { model: vendor.and_then(|vendor| {
vendor vendor
.devices .devices
.get(device_id) .get(&device_id.to_ascii_lowercase())
.map(|device| device.name.clone()) .map(|device| device.name.clone())
}), }),
}, },

View File

@ -921,6 +921,7 @@ fn load_controllers(base_path: &Path) -> anyhow::Result<BTreeMap<String, Box<dyn
} }
}); });
#[cfg(not(test))]
let nvml: LazyCell<Option<Rc<Nvml>>> = LazyCell::new(|| match Nvml::init() { let nvml: LazyCell<Option<Rc<Nvml>>> = LazyCell::new(|| match Nvml::init() {
Ok(nvml) => { Ok(nvml) => {
info!("Nvidia management library loaded"); info!("Nvidia management library loaded");
@ -931,7 +932,10 @@ fn load_controllers(base_path: &Path) -> anyhow::Result<BTreeMap<String, Box<dyn
None None
} }
}); });
#[cfg(test)]
let nvml: LazyCell<Option<Rc<Nvml>>> = LazyCell::new(|| None);
#[cfg(not(test))]
let amd_drm: LazyCell<Option<LibDrmAmdgpu>> = LazyCell::new(|| match LibDrmAmdgpu::new() { let amd_drm: LazyCell<Option<LibDrmAmdgpu>> = LazyCell::new(|| match LibDrmAmdgpu::new() {
Ok(drm) => { Ok(drm) => {
info!("AMDGPU DRM initialized"); info!("AMDGPU DRM initialized");
@ -942,6 +946,8 @@ fn load_controllers(base_path: &Path) -> anyhow::Result<BTreeMap<String, Box<dyn
None None
} }
}); });
#[cfg(test)]
let amd_drm: LazyCell<Option<LibDrmAmdgpu>> = LazyCell::new(|| None);
for entry in base_path for entry in base_path
.read_dir() .read_dir()