fix: check for DEVTYPE=drm_minor when trying to find usable gpu paths instead of using the name

This commit is contained in:
Ilya Zlobintsev 2023-04-22 10:27:47 +03:00
parent b461106edd
commit 0bc59a02cc

View File

@ -8,7 +8,7 @@ use lact_schema::{
};
use std::{
collections::HashMap,
env,
env, fs,
path::PathBuf,
sync::{Arc, RwLock},
};
@ -35,11 +35,8 @@ impl<'a> Handler {
{
let entry = entry?;
let name = entry
.file_name()
.into_string()
.map_err(|_| anyhow!("non-utf path"))?;
if name.starts_with("card") && !name.contains('-') {
if let Ok(drm_uevent) = fs::read_to_string(entry.path().join("uevent")) {
if drm_uevent.contains("DEVTYPE=drm_minor") {
trace!("trying gpu controller at {:?}", entry.path());
let device_path = entry.path().join("device");
match GpuController::new_from_path(device_path) {
@ -60,6 +57,7 @@ impl<'a> Handler {
}
}
}
}
let handler = Self {
gpu_controllers: Arc::new(controllers),