feat: add support for not cleaning up clocks table on shutdown (#133)

This commit is contained in:
Ilya Zlobintsev
2023-03-19 15:04:39 +02:00
committed by GitHub
parent 4594baa7f5
commit f5269067db
3 changed files with 14 additions and 2 deletions

View File

@@ -20,6 +20,8 @@ pub struct Config {
pub struct Daemon {
pub log_level: String,
pub admin_groups: Vec<String>,
#[serde(default)]
pub disable_clocks_cleanup: bool,
}
impl Default for Daemon {
@@ -27,6 +29,7 @@ impl Default for Daemon {
Self {
log_level: "info".to_owned(),
admin_groups: DEFAULT_ADMIN_GROUPS.map(str::to_owned).to_vec(),
disable_clocks_cleanup: false,
}
}
}

View File

@@ -441,6 +441,8 @@ impl GpuController {
table.set_max_voltage(voltage)?;
}
debug!("writing clocks commands: {:#?}", table.get_commands()?);
self.handle
.set_clocks_table(&table)
.context("Could not write clocks table")?;

View File

@@ -258,10 +258,17 @@ impl<'a> Handler {
}
pub async fn cleanup(self) {
let disable_clocks_cleanup = self
.config
.try_read()
.map(|config| config.daemon.disable_clocks_cleanup)
.unwrap_or(false);
for (id, controller) in self.gpu_controllers.iter() {
if controller.handle.get_clocks_table().is_ok() {
if !disable_clocks_cleanup && controller.handle.get_clocks_table().is_ok() {
debug!("resetting clocks table");
if let Err(err) = controller.handle.reset_clocks_table() {
error!("Could not reset the clocks table: {err}");
error!("could not reset the clocks table: {err}");
}
}