Merge pull request #41 from Eraden/invalid-pid-and-ensure-manual-mode
Ensure manual mode is enabled. Clean pid file at exit
This commit is contained in:
commit
30f5654ff5
99
Cargo.lock
generated
99
Cargo.lock
generated
@ -4,9 +4,9 @@ version = 3
|
||||
|
||||
[[package]]
|
||||
name = "ab_glyph"
|
||||
version = "0.2.14"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d54a65e0d4f66f8536c98cb3ca81ca33b7e2ca43442465507a3a62291ec0d9e4"
|
||||
checksum = "24606928a235e73cdef55a0c909719cadd72fce573e5713d58cb2952d8f5794c"
|
||||
dependencies = [
|
||||
"ab_glyph_rasterizer",
|
||||
"owned_ttf_parser 0.15.0",
|
||||
@ -56,13 +56,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "amdfand"
|
||||
version = "1.0.9"
|
||||
version = "1.0.11"
|
||||
dependencies = [
|
||||
"amdgpu",
|
||||
"amdgpu-config",
|
||||
"gumdrop",
|
||||
"log",
|
||||
"pidlock",
|
||||
"pretty_env_logger",
|
||||
"ron 0.1.7",
|
||||
"serde",
|
||||
@ -532,9 +531,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.5.2"
|
||||
version = "0.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa"
|
||||
checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"crossbeam-utils",
|
||||
@ -553,10 +552,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.7"
|
||||
version = "0.9.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c00d6d2ea26e8b151d99093005cb442fb9a37aeaca582a03ec70946f49ab5ed9"
|
||||
checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cfg-if 1.0.0",
|
||||
"crossbeam-utils",
|
||||
"lazy_static",
|
||||
@ -566,9 +566,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-queue"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4dd435b205a4842da59efd07628f921c096bc1cc0a156835b4fa0bcb9a19bcce"
|
||||
checksum = "1f25d8400f4a7a5778f0e4e52384a48cbd9b5c495d110786187fc750075277a2"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"crossbeam-utils",
|
||||
@ -576,9 +576,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.7"
|
||||
version = "0.8.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6"
|
||||
checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"lazy_static",
|
||||
@ -668,9 +668,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.3.6"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780"
|
||||
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"redox_users",
|
||||
@ -862,7 +862,7 @@ checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
"wasi",
|
||||
"wasi 0.10.0+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -984,18 +984,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gumdrop"
|
||||
version = "0.8.0"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46571f5d540478cf70d2a42dd0d6d8e9f4b9cc7531544b93311e657b86568a0b"
|
||||
checksum = "5bc700f989d2f6f0248546222d9b4258f5b02a171a431f8285a81c08142629e3"
|
||||
dependencies = [
|
||||
"gumdrop_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gumdrop_derive"
|
||||
version = "0.8.0"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "915ef07c710d84733522461de2a734d4d62a3fd39a4d4f404c2f385ef8618d05"
|
||||
checksum = "729f9bd3449d77e7831a18abfb7ba2f99ee813dfd15b8c2167c9a54ba20aa99d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -1107,9 +1107,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.119"
|
||||
version = "0.2.121"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4"
|
||||
checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
@ -1237,14 +1237,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "0.8.0"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba272f85fa0b41fc91872be579b3bbe0f56b792aa361a380eb669469f68dafb2"
|
||||
checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"miow",
|
||||
"ntapi",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
@ -1372,13 +1373,12 @@ checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.1.0"
|
||||
version = "7.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109"
|
||||
checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"minimal-lexical",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1421,18 +1421,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "num_enum"
|
||||
version = "0.5.6"
|
||||
version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "720d3ea1055e4e4574c0c0b0f8c3fd4f24c4cdaf465948206dea090b57b526ad"
|
||||
checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9"
|
||||
dependencies = [
|
||||
"num_enum_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum_derive"
|
||||
version = "0.5.6"
|
||||
version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d992b768490d7fe0d8586d9b5745f6c49f557da6d81dc982b1d167ad4edbb21"
|
||||
checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce"
|
||||
dependencies = [
|
||||
"proc-macro-crate 1.1.3",
|
||||
"proc-macro2",
|
||||
@ -1490,9 +1490,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.9.0"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
|
||||
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
|
||||
|
||||
[[package]]
|
||||
name = "osmesa-sys"
|
||||
@ -1652,9 +1652,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.15"
|
||||
version = "1.0.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
|
||||
checksum = "b4af2ec4714533fcdf07e886f17025ace8b997b9ce51204ee69b6da831c3da57"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
@ -1680,28 +1680,29 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.10"
|
||||
version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"
|
||||
checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.4.0"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
|
||||
checksum = "7776223e2696f1aa4c6b0170e83212f47296a00424305117d013dfe86fb0fe55"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"redox_syscall",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.5.4"
|
||||
version = "1.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
|
||||
checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@ -1942,9 +1943,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.86"
|
||||
version = "1.0.89"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b"
|
||||
checksum = "ea297be220d52398dcc07ce15a209fce436d361735ac1db700cab3b6cdfb9f54"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -1959,9 +1960,9 @@ checksum = "36ae8932fcfea38b7d3883ae2ab357b0d57a02caaa18ebb4f5ece08beaec4aa0"
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.2"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
|
||||
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
@ -1993,7 +1994,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"wasi",
|
||||
"wasi 0.10.0+wasi-snapshot-preview1",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
@ -2006,7 +2007,7 @@ dependencies = [
|
||||
"bytes",
|
||||
"libc",
|
||||
"memchr",
|
||||
"mio 0.8.0",
|
||||
"mio 0.8.2",
|
||||
"num_cpus",
|
||||
"once_cell",
|
||||
"parking_lot 0.12.0",
|
||||
@ -2141,6 +2142,12 @@ version = "0.10.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.79"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "amdfand"
|
||||
version = "1.0.9"
|
||||
version = "1.0.11"
|
||||
edition = "2018"
|
||||
description = "AMDGPU fan control service"
|
||||
license = "MIT OR Apache-2.0"
|
||||
@ -22,8 +22,6 @@ gumdrop = { version = "0.8.0" }
|
||||
log = { version = "0.4.14" }
|
||||
pretty_env_logger = { version = "0.4.0" }
|
||||
|
||||
pidlock = { version = "0.1.4" }
|
||||
|
||||
[dev-dependencies]
|
||||
amdgpu = { path = "../amdgpu", version = "1.0" }
|
||||
amdgpu-config = { path = "../amdgpu-config", version = "1.0", features = ["fan"] }
|
||||
|
@ -3,7 +3,7 @@ use gumdrop::Options;
|
||||
use amdgpu::hw_mon::HwMon;
|
||||
use amdgpu::utils::{linear_map, load_temp_inputs};
|
||||
use amdgpu::{
|
||||
utils, TempInput, PULSE_WIDTH_MODULATION_AUTO, PULSE_WIDTH_MODULATION_MAX,
|
||||
utils, TempInput, PULSE_WIDTH_MODULATION_MANUAL, PULSE_WIDTH_MODULATION_MAX,
|
||||
PULSE_WIDTH_MODULATION_MIN, PULSE_WIDTH_MODULATION_MODE,
|
||||
};
|
||||
use amdgpu_config::fan::Config;
|
||||
@ -116,7 +116,7 @@ impl Fan {
|
||||
|
||||
/// Change fan speed to given value with checking min-max range
|
||||
fn write_pwm(&self, value: u64) -> crate::Result<()> {
|
||||
if self.is_fan_automatic() {
|
||||
if !self.is_fan_manual() {
|
||||
self.write_manual()?;
|
||||
}
|
||||
self.hw_mon_write("pwm1", value)
|
||||
@ -125,9 +125,9 @@ impl Fan {
|
||||
}
|
||||
|
||||
/// Check if gpu fan is managed by GPU embedded manager
|
||||
pub fn is_fan_automatic(&self) -> bool {
|
||||
pub fn is_fan_manual(&self) -> bool {
|
||||
self.hw_mon_read(PULSE_WIDTH_MODULATION_MODE)
|
||||
.map(|s| s.as_str() == PULSE_WIDTH_MODULATION_AUTO)
|
||||
.map(|s| s.as_str() == PULSE_WIDTH_MODULATION_MANUAL)
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
@ -166,10 +166,10 @@ impl Fan {
|
||||
if self.pwm_min.is_none() {
|
||||
self.pwm_min = Some(self.value_or(PULSE_WIDTH_MODULATION_MIN, 0));
|
||||
};
|
||||
self.pwm_min.unwrap_or_default()
|
||||
self.pwm_min.unwrap_or(0)
|
||||
}
|
||||
|
||||
/// Read minimal fan speed. Usually this is 255
|
||||
/// Read maximal fan speed. Usually this is 255
|
||||
pub fn pwm_max(&mut self) -> u32 {
|
||||
if self.pwm_max.is_none() {
|
||||
self.pwm_max = Some(self.value_or(PULSE_WIDTH_MODULATION_MAX, 255));
|
||||
|
@ -16,6 +16,16 @@ pub fn run(mut config: Config) -> crate::Result<()> {
|
||||
if hw_mons.is_empty() {
|
||||
return Err(AmdFanError::NoHwMonFound);
|
||||
}
|
||||
hw_mons.iter().for_each(|fan| {
|
||||
if let Err(e) = fan.write_manual() {
|
||||
log::debug!(
|
||||
"Failed to switch to manual fan manipulation for fan {:?}. {:?}",
|
||||
fan.hw_mon,
|
||||
e
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
let mut cache = std::collections::HashMap::new();
|
||||
loop {
|
||||
if is_reload_required() {
|
||||
|
@ -31,6 +31,7 @@ pub static PULSE_WIDTH_MODULATION: &str = "pwm1";
|
||||
pub static PULSE_WIDTH_MODULATION_MODE: &str = "pwm1_enable";
|
||||
|
||||
// static PULSE_WIDTH_MODULATION_DISABLED: &str = "0";
|
||||
pub static PULSE_WIDTH_MODULATION_MANUAL: &str = "1";
|
||||
pub static PULSE_WIDTH_MODULATION_AUTO: &str = "2";
|
||||
|
||||
static mut RELOAD_CONFIG: bool = false;
|
||||
|
@ -10,3 +10,7 @@ command_background=true
|
||||
depend() {
|
||||
need udev
|
||||
}
|
||||
|
||||
stop_pre() {
|
||||
rm /var/lib/amdfand/amdfand.pid
|
||||
}
|
||||
|
@ -1,10 +1,15 @@
|
||||
[Unit]
|
||||
Description=AMD GPU fan daemon
|
||||
After=sysinit.target local-fs.target
|
||||
|
||||
[Service]
|
||||
Restart=on-failure
|
||||
RestartSec=4
|
||||
|
||||
ExecStart=/usr/bin/amdfand service
|
||||
ExecStopPost=rm /var/lib/amdfand/amdfand.pid
|
||||
|
||||
Environment=RUST_LOG=ERROR
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
@ -10,3 +10,7 @@ command_background=true
|
||||
depend() {
|
||||
need udev
|
||||
}
|
||||
|
||||
stop_pre() {
|
||||
rm /var/lib/amdgui/helper.pid /var/lib/amdfand/helper.sock
|
||||
}
|
||||
|
@ -1,10 +1,15 @@
|
||||
[Unit]
|
||||
Description=AMD GPU gui helper
|
||||
After=sysinit.target local-fs.target
|
||||
|
||||
[Service]
|
||||
Restart=on-failure
|
||||
RestartSec=4
|
||||
|
||||
ExecStart=/usr/bin/amdgui-helper
|
||||
ExecStopPost=rm /var/lib/amdgui/helper.pid /var/lib/amdfand/helper.sock
|
||||
|
||||
Environment=RUST_LOG=ERROR
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
@ -1,10 +1,14 @@
|
||||
[Unit]
|
||||
Description=AMD GPU monitoring tool
|
||||
After=sysinit.target local-fs.target
|
||||
|
||||
[Service]
|
||||
Restart=on-failure
|
||||
RestartSec=4
|
||||
|
||||
ExecStart=/usr/bin/amdmond log_file -s /var/log/amdmon.csv
|
||||
|
||||
Environment=RUST_LOG=ERROR
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
@ -1,10 +1,14 @@
|
||||
[Unit]
|
||||
Description=AMD GPU voltage daemon
|
||||
After=sysinit.target local-fs.target
|
||||
|
||||
[Service]
|
||||
Restart=on-failure
|
||||
RestartSec=4
|
||||
|
||||
ExecStart=/usr/bin/amdvold service
|
||||
|
||||
Environment=RUST_LOG=ERROR
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
Loading…
Reference in New Issue
Block a user