style: cargo fmt the nvidia changes
This commit is contained in:
parent
5103b57be9
commit
33b0b1df77
3 changed files with 46 additions and 31 deletions
|
|
@ -311,8 +311,18 @@ impl NvidiaPlan {
|
||||||
// only accelerate one of them.
|
// only accelerate one of them.
|
||||||
let open_only: Vec<String> = supported
|
let open_only: Vec<String> = supported
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|d| d.generation.map(|g| g.requires_open_modules()).unwrap_or(false))
|
.filter(|d| {
|
||||||
.map(|d| format!("{} ({})", d.pci_id, d.generation.map(|g| g.as_str()).unwrap_or("unknown")))
|
d.generation
|
||||||
|
.map(|g| g.requires_open_modules())
|
||||||
|
.unwrap_or(false)
|
||||||
|
})
|
||||||
|
.map(|d| {
|
||||||
|
format!(
|
||||||
|
"{} ({})",
|
||||||
|
d.pci_id,
|
||||||
|
d.generation.map(|g| g.as_str()).unwrap_or("unknown")
|
||||||
|
)
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let prop_only: Vec<String> = supported
|
let prop_only: Vec<String> = supported
|
||||||
.iter()
|
.iter()
|
||||||
|
|
@ -321,7 +331,13 @@ impl NvidiaPlan {
|
||||||
.map(|g| g.requires_proprietary_modules())
|
.map(|g| g.requires_proprietary_modules())
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
})
|
})
|
||||||
.map(|d| format!("{} ({})", d.pci_id, d.generation.map(|g| g.as_str()).unwrap_or("unknown")))
|
.map(|d| {
|
||||||
|
format!(
|
||||||
|
"{} ({})",
|
||||||
|
d.pci_id,
|
||||||
|
d.generation.map(|g| g.as_str()).unwrap_or("unknown")
|
||||||
|
)
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
return Self {
|
return Self {
|
||||||
devices,
|
devices,
|
||||||
|
|
@ -623,20 +639,14 @@ impl LiveNvidiaPlan {
|
||||||
o.push_str(&format!(
|
o.push_str(&format!(
|
||||||
"device={} {}\n",
|
"device={} {}\n",
|
||||||
device.pci_id,
|
device.pci_id,
|
||||||
device
|
device.generation.map(|g| g.as_str()).unwrap_or("unknown")
|
||||||
.generation
|
|
||||||
.map(|g| g.as_str())
|
|
||||||
.unwrap_or("unknown")
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
for device in &self.unclaimed {
|
for device in &self.unclaimed {
|
||||||
o.push_str(&format!(
|
o.push_str(&format!(
|
||||||
"unclaimed={} {}\n",
|
"unclaimed={} {}\n",
|
||||||
device.pci_id,
|
device.pci_id,
|
||||||
device
|
device.generation.map(|g| g.as_str()).unwrap_or("unknown")
|
||||||
.generation
|
|
||||||
.map(|g| g.as_str())
|
|
||||||
.unwrap_or("unknown")
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
o.push_str(&format!("reason={}\n", self.reason));
|
o.push_str(&format!("reason={}\n", self.reason));
|
||||||
|
|
@ -848,7 +858,11 @@ mod tests {
|
||||||
assert!(!plan.supported);
|
assert!(!plan.supported);
|
||||||
assert_eq!(plan.branch, "nouveau");
|
assert_eq!(plan.branch, "nouveau");
|
||||||
assert_eq!(plan.flavor, None);
|
assert_eq!(plan.flavor, None);
|
||||||
assert!(plan.reason.contains("no single NVIDIA branch"), "{}", plan.reason);
|
assert!(
|
||||||
|
plan.reason.contains("no single NVIDIA branch"),
|
||||||
|
"{}",
|
||||||
|
plan.reason
|
||||||
|
);
|
||||||
assert!(plan.gentoo_atom().is_none());
|
assert!(plan.gentoo_atom().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -194,9 +194,7 @@ fn embedded_version(name: &str, prefix: &str) -> Option<String> {
|
||||||
if version.is_empty()
|
if version.is_empty()
|
||||||
|| !version.chars().next()?.is_ascii_digit()
|
|| !version.chars().next()?.is_ascii_digit()
|
||||||
|| !version.contains('.')
|
|| !version.contains('.')
|
||||||
|| !version
|
|| !version.chars().all(|c| c.is_ascii_digit() || c == '.')
|
||||||
.chars()
|
|
||||||
.all(|c| c.is_ascii_digit() || c == '.')
|
|
||||||
{
|
{
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
@ -470,9 +468,8 @@ pub fn verify_live_nvidia(
|
||||||
|
|
||||||
// The live-only load script must be present; a machine without an NVIDIA
|
// The live-only load script must be present; a machine without an NVIDIA
|
||||||
// GPU must never record a failed unit.
|
// GPU must never record a failed unit.
|
||||||
let load = resolve_in_rootfs(rootfs, "usr/local/bin/phoebus-nvidia-load").filter(|p| {
|
let load =
|
||||||
size_of(p) > 0
|
resolve_in_rootfs(rootfs, "usr/local/bin/phoebus-nvidia-load").filter(|p| size_of(p) > 0);
|
||||||
});
|
|
||||||
if load.is_none() {
|
if load.is_none() {
|
||||||
return Err(fail(
|
return Err(fail(
|
||||||
"usr/local/bin/phoebus-nvidia-load is missing or empty (gated driver load)".into(),
|
"usr/local/bin/phoebus-nvidia-load is missing or empty (gated driver load)".into(),
|
||||||
|
|
@ -567,11 +564,7 @@ mod tests {
|
||||||
touch(&root.join("usr/local/bin/phoebus-nvidia-load"));
|
touch(&root.join("usr/local/bin/phoebus-nvidia-load"));
|
||||||
let conf = root.join("etc/modprobe.d/phoebus-nvidia.conf");
|
let conf = root.join("etc/modprobe.d/phoebus-nvidia.conf");
|
||||||
std::fs::create_dir_all(conf.parent().unwrap()).unwrap();
|
std::fs::create_dir_all(conf.parent().unwrap()).unwrap();
|
||||||
std::fs::write(
|
std::fs::write(&conf, b"blacklist nouveau\noptions nvidia_drm modeset=1\n").unwrap();
|
||||||
&conf,
|
|
||||||
b"blacklist nouveau\noptions nvidia_drm modeset=1\n",
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -593,8 +586,12 @@ mod tests {
|
||||||
complete_rootfs(dir.path());
|
complete_rootfs(dir.path());
|
||||||
// The dpkg version carries a Debian revision; the libs and firmware do
|
// The dpkg version carries a Debian revision; the libs and firmware do
|
||||||
// not.
|
// not.
|
||||||
verify_live_nvidia(dir.path(), "550.163.01-1~deb13u1", NvidiaModuleFlavor::Proprietary)
|
verify_live_nvidia(
|
||||||
.unwrap();
|
dir.path(),
|
||||||
|
"550.163.01-1~deb13u1",
|
||||||
|
NvidiaModuleFlavor::Proprietary,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -710,8 +707,9 @@ mod tests {
|
||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
complete_rootfs(dir.path());
|
complete_rootfs(dir.path());
|
||||||
write_bytes(
|
write_bytes(
|
||||||
&dir.path()
|
&dir.path().join(format!(
|
||||||
.join(format!("usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.{DRIVER}")),
|
"usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.{DRIVER}"
|
||||||
|
)),
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
let err = verify_live_nvidia(dir.path(), DRIVER, NvidiaModuleFlavor::Proprietary)
|
let err = verify_live_nvidia(dir.path(), DRIVER, NvidiaModuleFlavor::Proprietary)
|
||||||
|
|
@ -725,8 +723,9 @@ mod tests {
|
||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
complete_rootfs(dir.path());
|
complete_rootfs(dir.path());
|
||||||
std::fs::rename(
|
std::fs::rename(
|
||||||
dir.path()
|
dir.path().join(format!(
|
||||||
.join(format!("usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.{DRIVER}")),
|
"usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.{DRIVER}"
|
||||||
|
)),
|
||||||
dir.path()
|
dir.path()
|
||||||
.join("usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.999.0.0"),
|
.join("usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.999.0.0"),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -256,12 +256,14 @@ pub fn probe_nvidia_display_devices(sysfs: &Path) -> Vec<GpuInfo> {
|
||||||
.ok()
|
.ok()
|
||||||
.map(|s| s.trim().to_string())
|
.map(|s| s.trim().to_string())
|
||||||
};
|
};
|
||||||
let (Some(class), Some(vendor), Some(device)) = (read("class"), read("vendor"), read("device"))
|
let (Some(class), Some(vendor), Some(device)) =
|
||||||
|
(read("class"), read("vendor"), read("device"))
|
||||||
else {
|
else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let parse = |s: &str| u32::from_str_radix(s.trim_start_matches("0x"), 16).ok();
|
let parse = |s: &str| u32::from_str_radix(s.trim_start_matches("0x"), 16).ok();
|
||||||
let (Some(class), Some(vendor), Some(device)) = (parse(&class), parse(&vendor), parse(&device))
|
let (Some(class), Some(vendor), Some(device)) =
|
||||||
|
(parse(&class), parse(&vendor), parse(&device))
|
||||||
else {
|
else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue