diff --git a/Cargo.lock b/Cargo.lock index 00097a13..1a44fc83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,8 +31,7 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "amdgpu-sysfs" -version = "0.21.0" -source = "git+https://github.com/ilya-zlobintsev/amdgpu-sysfs-rs.git?rev=215eafbcbca0fe28f66f8ba0cbcec0f547baaba1#215eafbcbca0fe28f66f8ba0cbcec0f547baaba1" +version = "0.21.1" dependencies = [ "enum_dispatch", "serde", diff --git a/Cargo.toml b/Cargo.toml index 23c71cae..65c53e9a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,8 @@ members = [ edition = "2024" [workspace.dependencies] -amdgpu-sysfs = { git = "https://github.com/ilya-zlobintsev/amdgpu-sysfs-rs.git", rev = "215eafbcbca0fe28f66f8ba0cbcec0f547baaba1", features = ["serde"] } +#amdgpu-sysfs = { git = "https://github.com/ilya-zlobintsev/amdgpu-sysfs-rs.git", rev = "215eafbcbca0fe28f66f8ba0cbcec0f547baaba1", features = ["serde"] } +amdgpu-sysfs = { path = "../amdgpu-sysfs-rs", features = ["serde"] } nvml-wrapper = { git = "https://github.com/rust-nvml/nvml-wrapper.git", rev = "eb47417eede43443f139053479618e96ad32893d" } serde = { version = "1.0", features = ["derive"] } serde_with = { version = "3.21.0", default-features = false, features = [ diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 52d253cb..4a4ac153 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -213,6 +213,10 @@ gpus: mem_clock_offsets: 0: 200 + # Index of the UMA (dedicated VRAM) configuration that should be used. + # Needs a reboot to actually take effect. Applicable to certain AMD iGPUs. + uma_carveout: 1 + # Settings profiles profiles: # Name of the profile diff --git a/lact-daemon/src/config.rs b/lact-daemon/src/config.rs index eb7b4d17..b6e56063 100644 --- a/lact-daemon/src/config.rs +++ b/lact-daemon/src/config.rs @@ -495,7 +495,7 @@ mod tests { use indexmap::IndexMap; use insta::assert_yaml_snapshot; use lact_schema::{ - FanControlMode, NvidiaThermalOptions, NvidiaVfPoint, PmfwOptions, + FanControlMode, NvidiaVfPoint, PmfwOptions, config::{ ClocksConfiguration, CurvePoint, FanControlSettings, FanCurve, GpuConfig, NvidiaCurvePoint, @@ -601,20 +601,7 @@ mod tests { #[test] fn clocks_configuration_applied() { - let mut gpu = GpuConfig { - fan_control_enabled: false, - fan_control_settings: None, - pmfw_options: PmfwOptions::default(), - nvidia_thermal_options: NvidiaThermalOptions::default(), - power_mizer_mode: None, - power_cap: None, - performance_level: None, - clocks_configuration: ClocksConfiguration::default(), - power_profile_mode_index: None, - custom_power_profile_mode_hueristics: vec![], - power_states: IndexMap::new(), - }; - + let mut gpu = GpuConfig::default(); assert!(!gpu.is_core_clocks_used()); gpu.clocks_configuration.voltage_offset = Some(10); assert!(gpu.is_core_clocks_used()); diff --git a/lact-daemon/src/server/gpu_controller/amd.rs b/lact-daemon/src/server/gpu_controller/amd.rs index 1124ecd1..9002a788 100644 --- a/lact-daemon/src/server/gpu_controller/amd.rs +++ b/lact-daemon/src/server/gpu_controller/amd.rs @@ -23,10 +23,10 @@ use drm::{DrmProvider, amdgpu::AmdGpuDrmProvider}; use futures::{FutureExt, future::LocalBoxFuture}; use indexmap::IndexMap; use lact_schema::{ - ActivePowerStates, AmdCacheInstance, CacheInfo, CacheType, ClocksInfo, ClockspeedStats, - DeviceApiInfo, DeviceFlag, DeviceInfo, DeviceStats, DeviceType, DrmInfo, FanControlMode, - FanStats, LinkInfo, NvidiaThermalInfo, PmfwInfo, PowerState, PowerStates, PowerStats, - ProcessList, ProcessUtilizationType, TemperatureEntry, VoltageStats, VramStats, + ActivePowerStates, AmdCacheInstance, AmdUmaCarveout, CacheInfo, CacheType, ClocksInfo, + ClockspeedStats, DeviceApiInfo, DeviceFlag, DeviceInfo, DeviceStats, DeviceType, DrmInfo, + FanControlMode, FanStats, LinkInfo, NvidiaThermalInfo, PmfwInfo, PowerState, PowerStates, + PowerStats, ProcessList, ProcessUtilizationType, TemperatureEntry, VoltageStats, VramStats, config::{ClocksConfiguration, FanControlSettings, FanCurve, GpuConfig}, }; #[cfg(feature = "display-info")] @@ -567,6 +567,18 @@ impl AmdGpuController { .ok() }); + let amd_uma_carveout = self + .handle + .get_uma_carveout_options() + .and_then(|options| { + let current = self.handle.get_current_uma_carveout()?; + Ok(AmdUmaCarveout { + options: options.options, + current, + }) + }) + .ok(); + trace!("Reading DRM info"); let drm_handle = self.drm_handle.as_ref(); @@ -575,6 +587,7 @@ impl AmdGpuController { None => Some(DrmInfo { cache_info, vram_clock_ratio: 1.0, + amd_uma_carveout, ..Default::default() }), } diff --git a/lact-daemon/src/server/gpu_controller/nvidia.rs b/lact-daemon/src/server/gpu_controller/nvidia.rs index 8b2d9968..de5787d0 100644 --- a/lact-daemon/src/server/gpu_controller/nvidia.rs +++ b/lact-daemon/src/server/gpu_controller/nvidia.rs @@ -855,6 +855,7 @@ impl GpuController for NvidiaGpuController { .ok(), amd_ip_info: vec![], intel: IntelDrmInfo::default(), + ..Default::default() }), flags: vec![ DeviceFlag::ConfigurableFanControl, diff --git a/lact-daemon/src/snapshots/lact_daemon__config__tests__parse_doc.snap b/lact-daemon/src/snapshots/lact_daemon__config__tests__parse_doc.snap index 852f0c3d..5364f798 100644 --- a/lact-daemon/src/snapshots/lact_daemon__config__tests__parse_doc.snap +++ b/lact-daemon/src/snapshots/lact_daemon__config__tests__parse_doc.snap @@ -103,6 +103,7 @@ gpus: memory_clock: - 0 - 1 + uma_carveout: 1 profiles: vkcube: rule: diff --git a/lact-daemon/src/tests/snapshots/lact_daemon__tests__amd__strixpoint.snap b/lact-daemon/src/tests/snapshots/lact_daemon__tests__amd__strixpoint.snap index 2b58407c..ce028004 100644 --- a/lact-daemon/src/tests/snapshots/lact_daemon__tests__amd__strixpoint.snap +++ b/lact-daemon/src/tests/snapshots/lact_daemon__tests__amd__strixpoint.snap @@ -39,6 +39,43 @@ expression: device_info "info": { "driver": "amdgpu", "drm_info": { + "amd_uma_carveout": { + "current": 0, + "options": [ + { + "name": "Minimum", + "size_bytes": 536870912 + }, + { + "name": null, + "size_bytes": 1073741824 + }, + { + "name": null, + "size_bytes": 2147483648 + }, + { + "name": null, + "size_bytes": 4294967296 + }, + { + "name": null, + "size_bytes": 6442450944 + }, + { + "name": "Medium", + "size_bytes": 8589934592 + }, + { + "name": null, + "size_bytes": 12884901888 + }, + { + "name": "High", + "size_bytes": 17179869184 + } + ] + }, "cache_info": { "Amd": [ [ diff --git a/lact-schema/src/config.rs b/lact-schema/src/config.rs index 8c3859ae..be509cc2 100644 --- a/lact-schema/src/config.rs +++ b/lact-schema/src/config.rs @@ -53,6 +53,7 @@ pub struct GpuConfig { pub custom_power_profile_mode_hueristics: Vec>>, #[serde(default, skip_serializing_if = "IndexMap::is_empty")] pub power_states: IndexMap>, + pub uma_carveout: Option, } #[skip_serializing_none] diff --git a/lact-schema/src/lib.rs b/lact-schema/src/lib.rs index 89b83479..a981c693 100644 --- a/lact-schema/src/lib.rs +++ b/lact-schema/src/lib.rs @@ -15,7 +15,7 @@ pub use response::Response; use amdgpu_sysfs::{ gpu_handle::{ - PerformanceLevel, PowerLevelId, + PerformanceLevel, PowerLevelId, UmaCarveoutOption, fan_control::FanInfo, overdrive::{ClocksTable as _, ClocksTableGen as AmdClocksTableGen}, }, @@ -415,10 +415,19 @@ pub struct DrmInfo { pub memory_info: Option, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub amd_ip_info: Vec, + pub amd_uma_carveout: Option, #[serde(flatten)] pub intel: IntelDrmInfo, } +/// Options for iGPU UMA allocation +#[skip_serializing_none] +#[derive(Serialize, Deserialize, Debug, Clone, Default)] +pub struct AmdUmaCarveout { + pub options: Vec, + pub current: usize, +} + #[derive(Serialize, Deserialize, Debug, Clone, Default)] pub struct AmdIpInfo { pub ip_type: String, diff --git a/tests/snapshots/amd/strixpoint/card1/device/uma/carveout b/tests/snapshots/amd/strixpoint/card1/device/uma/carveout new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/tests/snapshots/amd/strixpoint/card1/device/uma/carveout @@ -0,0 +1 @@ +0 diff --git a/tests/snapshots/amd/strixpoint/card1/device/uma/carveout_options b/tests/snapshots/amd/strixpoint/card1/device/uma/carveout_options new file mode 100644 index 00000000..425bfbda --- /dev/null +++ b/tests/snapshots/amd/strixpoint/card1/device/uma/carveout_options @@ -0,0 +1,8 @@ +0: Minimum (512 MB) +1: (1 GB) +2: (2 GB) +3: (4 GB) +4: (6 GB) +5: Medium (8 GB) +6: (12 GB) +7: High (16 GB)