Revert "Fix: change epp change watch to a loop to prevent deadlock"

This reverts commit c06f78990f.
This commit is contained in:
Luke D. Jones
2023-12-08 20:00:58 +13:00
parent 922aa0c352
commit 694a644cc6

View File

@@ -1,14 +1,12 @@
use std::process::Command; use std::process::Command;
use std::sync::Arc; use std::sync::Arc;
use std::time::Duration;
use async_trait::async_trait; use async_trait::async_trait;
use config_traits::StdConfig; use config_traits::StdConfig;
use log::{error, info, warn}; use log::{debug, error, info, warn};
use rog_platform::cpu::{CPUControl, CPUEPP}; use rog_platform::cpu::CPUControl;
use rog_platform::platform::{GpuMode, PlatformPolicy, Properties, RogPlatform}; use rog_platform::platform::{GpuMode, PlatformPolicy, Properties, RogPlatform};
use rog_platform::power::AsusPower; use rog_platform::power::AsusPower;
use tokio::time::sleep;
use zbus::export::futures_util::lock::Mutex; use zbus::export::futures_util::lock::Mutex;
use zbus::fdo::Error as FdoErr; use zbus::fdo::Error as FdoErr;
use zbus::{dbus_interface, Connection, ObjectServer, SignalContext}; use zbus::{dbus_interface, Connection, ObjectServer, SignalContext};
@@ -672,38 +670,31 @@ impl CtrlTask for CtrlPlatform {
self.watch_nv_dynamic_boost(signal_ctxt.clone()).await?; self.watch_nv_dynamic_boost(signal_ctxt.clone()).await?;
self.watch_nv_temp_target(signal_ctxt.clone()).await?; self.watch_nv_temp_target(signal_ctxt.clone()).await?;
// let watch_throttle_thermal_policy = let watch_throttle_thermal_policy = self.platform.monitor_throttle_thermal_policy()?;
// self.platform.monitor_throttle_thermal_policy()?;
let ctrl = self.clone(); let ctrl = self.clone();
tokio::spawn(async move { tokio::spawn(async move {
let mut last_epp = CPUEPP::Default; use futures_lite::StreamExt;
loop { let mut buffer = [0; 32];
if let Ok(profile) = ctrl if let Ok(mut stream) = watch_throttle_thermal_policy.into_event_stream(&mut buffer) {
.platform while (stream.next().await).is_some() {
.get_throttle_thermal_policy() // this blocks
.map(PlatformPolicy::from) debug!("Platform: watch_throttle_thermal_policy changed");
.map_err(|e| { if let Ok(profile) = ctrl
error!("Platform: get_throttle_thermal_policy error: {e}"); .platform
}) .get_throttle_thermal_policy()
{ .map(PlatformPolicy::from)
if let Some(cpu) = ctrl.cpu_control.as_ref() { .map_err(|e| {
if let Ok(epp) = cpu.get_epp() { error!("Platform: get_throttle_thermal_policy error: {e}");
if last_epp != epp { })
info!( {
"PlatformPolicy setting EPP due to throttle_thermal_policy \ if let Some(cpu) = ctrl.cpu_control.as_ref() {
change" info!("PlatformPolicy setting EPP");
); cpu.set_epp(profile.into()).ok();
cpu.set_epp(profile.into()).ok();
last_epp = epp;
}
} }
ctrl.config.lock().await.platform_policy_to_restore = profile;
} }
ctrl.config.lock().await.platform_policy_to_restore = profile;
} }
// This needs to be a loop due to a conlict in fan_curves
// TODO: fix it
sleep(Duration::from_secs(1)).await;
} }
}); });