feat: disable thermals controls on rdna3+ when overdrive is disabled, as it is not writeable

This commit is contained in:
Ilya Zlobintsev 2024-01-14 12:24:52 +02:00
parent 57d419c92f
commit 20028cc101
8 changed files with 45 additions and 6 deletions

4
Cargo.lock generated
View File

@ -1397,9 +1397,9 @@ checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
[[package]] [[package]]
name = "libdrm_amdgpu_sys" name = "libdrm_amdgpu_sys"
version = "0.4.0" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "803eb16e071244ced33c3ff1078b70fb5c1fe6c7134c1b565e211e0788f496f7" checksum = "6badab42a333de99a838f765a5fe283a0eda3484d1e58dc753d53ef27881b252"
dependencies = [ dependencies = [
"libc", "libc",
] ]

View File

@ -33,7 +33,7 @@ serde_with = { version = "3.4.0", default-features = false, features = [
"macros", "macros",
] } ] }
zbus = { version = "3.14.1", default-features = false, features = ["tokio"] } zbus = { version = "3.14.1", default-features = false, features = ["tokio"] }
libdrm_amdgpu_sys = { optional = true, version = "0.4.0" } libdrm_amdgpu_sys = { optional = true, version = "0.4.1" }
tar = "0.4.40" tar = "0.4.40"
chrono = "0.4.31" chrono = "0.4.31"
os-release = "0.1.0" os-release = "0.1.0"

View File

@ -20,6 +20,9 @@ use tokio::{
}; };
use tracing::{debug, debug_span, info, warn, Instrument, Level}; use tracing::{debug, debug_span, info, warn, Instrument, Level};
/// RDNA3, minimum family that supports the new pmfw interface
pub const AMDGPU_FAMILY_GC_11_0_0: u32 = 145;
pub use server::system::MODULE_CONF_PATH; pub use server::system::MODULE_CONF_PATH;
const MIN_SYSTEM_UPTIME_SECS: f32 = 10.0; const MIN_SYSTEM_UPTIME_SECS: f32 = 10.0;

View File

@ -217,6 +217,7 @@ impl GpuController {
.and_then(|handle| handle.device_info().ok()) .and_then(|handle| handle.device_info().ok())
.map(|drm_info| DrmInfo { .map(|drm_info| DrmInfo {
family_name: drm_info.get_family_name().to_string(), family_name: drm_info.get_family_name().to_string(),
family_id: drm_info.family_id(),
asic_name: drm_info.get_asic_name().to_string(), asic_name: drm_info.get_asic_name().to_string(),
chip_class: drm_info.get_chip_class().to_string(), chip_class: drm_info.get_chip_class().to_string(),
compute_units: drm_info.cu_active_number, compute_units: drm_info.cu_active_number,

View File

@ -242,6 +242,7 @@ impl App {
self.root_stack.info_page.set_info(&info); self.root_stack.info_page.set_info(&info);
self.set_initial(gpu_id); self.set_initial(gpu_id);
self.root_stack.thermals_page.set_info(&info);
} }
fn set_initial(&self, gpu_id: &str) { fn set_initial(&self, gpu_id: &str) {

View File

@ -37,7 +37,7 @@ impl RootStack {
container.add_titled(&oc_page.container, Some("oc_page"), "OC"); container.add_titled(&oc_page.container, Some("oc_page"), "OC");
let thermals_page = ThermalsPage::new(); let thermals_page = ThermalsPage::new(&system_info);
container.add_titled(&thermals_page.container, Some("thermals_page"), "Thermals"); container.add_titled(&thermals_page.container, Some("thermals_page"), "Thermals");

View File

@ -5,13 +5,19 @@ use glib::clone;
use gtk::prelude::*; use gtk::prelude::*;
use gtk::*; use gtk::*;
use lact_client::schema::{ use lact_client::schema::{
default_fan_curve, DeviceStats, FanControlMode, FanCurveMap, PmfwOptions, default_fan_curve, DeviceInfo, DeviceStats, FanControlMode, FanCurveMap, PmfwOptions,
SystemInfo,
}; };
use lact_daemon::AMDGPU_FAMILY_GC_11_0_0;
use tracing::debug;
use self::{fan_curve_frame::FanCurveFrame, pmfw_frame::PmfwFrame}; use self::{fan_curve_frame::FanCurveFrame, pmfw_frame::PmfwFrame};
use super::{label_row, values_grid}; use super::{label_row, values_grid};
use crate::app::page_section::PageSection; use crate::app::page_section::PageSection;
const PMFW_WARNING: &str =
"Warning: Overclocking support is disabled, fan control functionality is not available.";
#[derive(Debug)] #[derive(Debug)]
pub struct ThermalsSettings { pub struct ThermalsSettings {
pub manual_fan_control: bool, pub manual_fan_control: bool,
@ -24,6 +30,7 @@ pub struct ThermalsSettings {
#[derive(Clone)] #[derive(Clone)]
pub struct ThermalsPage { pub struct ThermalsPage {
pub container: Box, pub container: Box,
pmfw_warning_label: Label,
temperatures_label: Label, temperatures_label: Label,
fan_speed_label: Label, fan_speed_label: Label,
pmfw_frame: PmfwFrame, pmfw_frame: PmfwFrame,
@ -31,10 +38,12 @@ pub struct ThermalsPage {
fan_curve_frame: FanCurveFrame, fan_curve_frame: FanCurveFrame,
fan_control_mode_stack: Stack, fan_control_mode_stack: Stack,
fan_control_mode_stack_switcher: StackSwitcher, fan_control_mode_stack_switcher: StackSwitcher,
overdrive_enabled: Option<bool>,
} }
impl ThermalsPage { impl ThermalsPage {
pub fn new() -> Self { pub fn new(system_info: &SystemInfo) -> Self {
let container = Box::builder() let container = Box::builder()
.orientation(Orientation::Vertical) .orientation(Orientation::Vertical)
.spacing(15) .spacing(15)
@ -42,6 +51,12 @@ impl ThermalsPage {
.margin_end(20) .margin_end(20)
.build(); .build();
let pmfw_warning_label = Label::builder()
.label(PMFW_WARNING)
.halign(Align::Start)
.build();
container.append(&pmfw_warning_label);
let stats_section = PageSection::new("Statistics"); let stats_section = PageSection::new("Statistics");
let stats_grid = values_grid(); let stats_grid = values_grid();
@ -88,6 +103,7 @@ impl ThermalsPage {
}); });
Self { Self {
pmfw_warning_label,
container, container,
temperatures_label, temperatures_label,
fan_speed_label, fan_speed_label,
@ -96,9 +112,25 @@ impl ThermalsPage {
fan_control_mode_stack, fan_control_mode_stack,
fan_control_mode_stack_switcher, fan_control_mode_stack_switcher,
pmfw_frame, pmfw_frame,
overdrive_enabled: system_info.amdgpu_overdrive_enabled,
} }
} }
pub fn set_info(&self, info: &DeviceInfo) {
let pmfw_disabled = info.drm_info.as_ref().is_some_and(|info| {
debug!(
"family id: {}, overdrive enabled {:?}",
info.family_id, self.overdrive_enabled
);
(info.family_id >= AMDGPU_FAMILY_GC_11_0_0) && (self.overdrive_enabled != Some(true))
});
self.pmfw_warning_label.set_visible(pmfw_disabled);
let sensitive = self.fan_control_mode_stack_switcher.is_sensitive() && !pmfw_disabled;
self.fan_control_mode_stack_switcher
.set_sensitive(sensitive);
}
pub fn set_stats(&self, stats: &DeviceStats, initial: bool) { pub fn set_stats(&self, stats: &DeviceStats, initial: bool) {
let mut temperatures: Vec<String> = stats let mut temperatures: Vec<String> = stats
.temps .temps

View File

@ -98,6 +98,8 @@ pub struct DeviceInfo<'a> {
#[derive(Serialize, Deserialize, Debug, Clone)] #[derive(Serialize, Deserialize, Debug, Clone)]
pub struct DrmInfo { pub struct DrmInfo {
pub family_name: String, pub family_name: String,
#[serde(default)]
pub family_id: u32,
pub asic_name: String, pub asic_name: String,
pub chip_class: String, pub chip_class: String,
pub compute_units: u32, pub compute_units: u32,