mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2025-02-25 18:55:26 -06:00
add power cap reset
This commit is contained in:
@@ -173,16 +173,22 @@ impl<'a> Handler {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_power_limit(&'a self, id: &str, limit: f64) -> anyhow::Result<()> {
|
||||
self.controller_by_id(id)?
|
||||
pub fn set_power_cap(&'a self, id: &str, maybe_cap: Option<f64>) -> anyhow::Result<()> {
|
||||
let hw_mon = self
|
||||
.controller_by_id(id)?
|
||||
.handle
|
||||
.hw_monitors
|
||||
.first()
|
||||
.context("GPU has no hardware monitor")?
|
||||
.set_power_cap(limit)?;
|
||||
.context("GPU has no hardware monitor")?;
|
||||
|
||||
let cap = match maybe_cap {
|
||||
Some(cap) => cap,
|
||||
None => hw_mon.get_power_cap_default()?,
|
||||
};
|
||||
hw_mon.set_power_cap(cap)?;
|
||||
|
||||
self.edit_gpu_config(id.to_owned(), |gpu_config| {
|
||||
gpu_config.power_cap = Some(limit);
|
||||
gpu_config.power_cap = maybe_cap;
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ async fn handle_request<'a>(request: Request<'a>, handler: &'a Handler) -> anyho
|
||||
Request::SetFanControl { id, enabled } => {
|
||||
ok_response(handler.set_fan_control(id, enabled).await?)
|
||||
}
|
||||
Request::SetPowerLimit { id, limit } => ok_response(handler.set_power_limit(id, limit)?),
|
||||
Request::SetPowerCap { id, cap } => ok_response(handler.set_power_cap(id, cap)?),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,5 +8,5 @@ pub enum Request<'a> {
|
||||
DeviceInfo { id: &'a str },
|
||||
DeviceStats { id: &'a str },
|
||||
SetFanControl { id: &'a str, enabled: bool },
|
||||
SetPowerLimit { id: &'a str, limit: f64 },
|
||||
SetPowerCap { id: &'a str, cap: Option<f64> },
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user