Skip to content

Commit

Permalink
fix(ARM): exclude ryzenadj if running on non-x86_64 hardware
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowApex committed Dec 30, 2024
1 parent 5cd8e5d commit 3606cff
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ dbus = "*"
pciutils = "*"

[dependencies]
libryzenadj = { git = "https://gitlab.com/shadowapex/libryzenadj-rs.git" }
log = "0.4.20"
simple_logger = "4.2.0"
tokio = { version = "*", features = ["full"] }
Expand All @@ -26,6 +25,9 @@ zbus_macros = "3.14.1"
rog_platform = { git = "https://gitlab.com/asus-linux/asusctl.git", default-features = true }
xdg = "2.5.2"

[target.'cfg(target_arch = "x86_64")'.dependencies]
libryzenadj = { git = "https://gitlab.com/shadowapex/libryzenadj-rs.git" }

[profile.release]
debug = false
strip = true
Expand Down
1 change: 1 addition & 0 deletions src/performance/gpu/amd/ryzenadj.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(target_arch = "x86_64")]
use std::error::Error;

use libryzenadj::RyzenAdj;
Expand Down
13 changes: 13 additions & 0 deletions src/performance/gpu/amd/tdp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ use crate::performance::gpu::{
tdp::{TDPDevice, TDPError, TDPResult},
};

#[cfg(target_arch = "x86_64")]
use super::ryzenadj::RyzenAdjTdp;

/// Implementation of TDP control for AMD GPUs
pub struct Tdp {
asus_wmi: Option<AsusWmi>,
acpi: Option<Acpi>,
#[cfg(target_arch = "x86_64")]
ryzenadj: Option<RyzenAdjTdp>,
}

Expand All @@ -31,6 +33,7 @@ impl Tdp {
None => None,
};

#[cfg(target_arch = "x86_64")]
let ryzenadj = match RyzenAdjTdp::new(path.to_string(), device_id.to_string()) {
Ok(ryzenadj) => {
log::info!("Found RyzenAdj interface for TDP control");
Expand All @@ -45,6 +48,7 @@ impl Tdp {
Tdp {
asus_wmi,
acpi,
#[cfg(target_arch = "x86_64")]
ryzenadj,
}
}
Expand All @@ -68,6 +72,7 @@ impl TDPDevice for Tdp {
};
};
// TODO: set platform profile based on % of max TDP.
#[cfg(target_arch = "x86_64")]
if self.ryzenadj.is_some() {
let ryzenadj = self.ryzenadj.as_ref().unwrap();
match ryzenadj.tdp().await {
Expand Down Expand Up @@ -99,6 +104,7 @@ impl TDPDevice for Tdp {
}
};
};
#[cfg(target_arch = "x86_64")]
if self.ryzenadj.is_some() {
let ryzenadj = self.ryzenadj.as_mut().unwrap();
match ryzenadj.set_tdp(value).await {
Expand Down Expand Up @@ -130,6 +136,7 @@ impl TDPDevice for Tdp {
}
};
};
#[cfg(target_arch = "x86_64")]
if self.ryzenadj.is_some() {
let ryzenadj = self.ryzenadj.as_ref().unwrap();
match ryzenadj.boost().await {
Expand Down Expand Up @@ -161,6 +168,7 @@ impl TDPDevice for Tdp {
}
};
};
#[cfg(target_arch = "x86_64")]
if self.ryzenadj.is_some() {
let ryzenadj = self.ryzenadj.as_mut().unwrap();
match ryzenadj.set_boost(value).await {
Expand All @@ -180,6 +188,7 @@ impl TDPDevice for Tdp {

async fn thermal_throttle_limit_c(&self) -> TDPResult<f64> {
log::info!("Get tctl limit");
#[cfg(target_arch = "x86_64")]
if self.ryzenadj.is_some() {
let ryzenadj = self.ryzenadj.as_ref().unwrap();
match ryzenadj.thermal_throttle_limit_c().await {
Expand All @@ -199,6 +208,7 @@ impl TDPDevice for Tdp {

async fn set_thermal_throttle_limit_c(&mut self, limit: f64) -> TDPResult<()> {
log::info!("Set tctl limit");
#[cfg(target_arch = "x86_64")]
if self.ryzenadj.is_some() {
let ryzenadj = self.ryzenadj.as_mut().unwrap();
match ryzenadj.set_thermal_throttle_limit_c(limit).await {
Expand Down Expand Up @@ -231,6 +241,7 @@ impl TDPDevice for Tdp {
};
};

#[cfg(target_arch = "x86_64")]
if self.ryzenadj.is_some() {
let ryzenadj = self.ryzenadj.as_ref().unwrap();
match ryzenadj.power_profile().await {
Expand Down Expand Up @@ -263,6 +274,7 @@ impl TDPDevice for Tdp {
};
};

#[cfg(target_arch = "x86_64")]
if self.ryzenadj.is_some() {
let ryzenadj = self.ryzenadj.as_mut().unwrap();
match ryzenadj.set_power_profile(profile.clone()).await {
Expand Down Expand Up @@ -293,6 +305,7 @@ impl TDPDevice for Tdp {
}
};
};
#[cfg(target_arch = "x86_64")]
if self.ryzenadj.is_some() {
let ryzenadj = self.ryzenadj.as_ref().unwrap();
match ryzenadj.power_profiles_available().await {
Expand Down

0 comments on commit 3606cff

Please sign in to comment.