mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2026-11-03 20:56:39 -06:00
feat: abstract AMD DRM
This commit is contained in:
1 parent
8caea2a5be
commit
e371c8debd
367 files changed
+2289
-132
No files matched your search
@@ -1,3 +1,5 @@
|
||||
mod drm;
|
||||
|
||||
use super::{CommonControllerInfo, FanControlHandle, GpuController, VENDOR_AMD};
|
||||
use crate::server::gpu_controller::common::{
|
||||
fan_control::FanCurveExt,
|
||||
@@ -15,20 +17,22 @@ use amdgpu_sysfs::{
|
||||
sysfs::SysFS,
|
||||
};
|
||||
use anyhow::{Context, anyhow, bail};
|
||||
#[cfg(feature = "mock")]
|
||||
use drm::mock::MockDrmProvider;
|
||||
use drm::{DrmProvider, amdgpu::AmdGpuDrmProvider};
|
||||
use futures::{FutureExt, future::LocalBoxFuture};
|
||||
use indexmap::IndexMap;
|
||||
use lact_schema::{
|
||||
ActivePowerStates, AmdCacheInstance, AmdIpInfo, CacheInfo, CacheType, ClocksInfo,
|
||||
ClockspeedStats, DeviceApiInfo, DeviceFlag, DeviceInfo, DeviceStats, DeviceType, DrmInfo,
|
||||
FanControlMode, FanStats, IntelDrmInfo, LinkInfo, NvidiaThermalInfo, PmfwInfo, PowerState,
|
||||
PowerStates, PowerStats, ProcessList, ProcessUtilizationType, RopInfo, TemperatureEntry,
|
||||
VoltageStats, VramStats,
|
||||
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,
|
||||
config::{ClocksConfiguration, FanControlSettings, FanCurve, GpuConfig},
|
||||
};
|
||||
#[cfg(feature = "display-info")]
|
||||
use lact_schema::{DisplayConnector, DisplaysInfo};
|
||||
use libdrm_amdgpu_sys::AMDGPU::{GpuMetrics, HW_IP::HW_IP_TYPE, ThrottlerBit, ThrottlerType};
|
||||
use libdrm_amdgpu_sys::{AMDGPU::SENSOR_INFO::SENSOR_TYPE, LibDrmAmdgpu, PCI};
|
||||
use libdrm_amdgpu_sys::AMDGPU::{GpuMetrics, MetricsInfo, ThrottlerBit, ThrottlerType};
|
||||
use libdrm_amdgpu_sys::{LibDrmAmdgpu, PCI};
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
cmp,
|
||||
@@ -41,11 +45,6 @@ use std::{collections::BTreeMap, fs, time::Instant};
|
||||
use tokio::{select, sync::Notify, time::sleep};
|
||||
use tracing::{debug, error, info, trace, warn};
|
||||
|
||||
use {
|
||||
lact_schema::DrmMemoryInfo,
|
||||
libdrm_amdgpu_sys::AMDGPU::{DeviceHandle as DrmHandle, GPU_INFO, MetricsInfo},
|
||||
};
|
||||
|
||||
/// RDNA3 - minimum family with PMFW
|
||||
const AMDGPU_FAMILY_GC_11_0_0: u32 = 145;
|
||||
|
||||
@@ -66,7 +65,6 @@ const REQUIRE_MANUAL_DEVICE_IDS: [&str; 19] = [
|
||||
// https://github.com/torvalds/linux/blob/v7.2/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0.c#L1809
|
||||
"1114", "150E", "1586", "1902", // Strix, Krackan
|
||||
];
|
||||
const AMDGPU_IDS_FLAGS_FUSION: u64 = 0x1;
|
||||
const HSA_CACHE_TYPE_DATA: u32 = 0x0000_0001;
|
||||
const HSA_CACHE_TYPE_INSTRUCTION: u32 = 0x0000_0002;
|
||||
const HSA_CACHE_TYPE_CPU: u32 = 0x0000_0004;
|
||||
@@ -81,22 +79,9 @@ const DRM_ENGINES: &[(&str, ProcessUtilizationType)] = &[
|
||||
("enc_1", ProcessUtilizationType::Encode),
|
||||
];
|
||||
|
||||
const ALL_HW_IP: &[HW_IP_TYPE] = &[
|
||||
HW_IP_TYPE::GFX,
|
||||
HW_IP_TYPE::COMPUTE,
|
||||
HW_IP_TYPE::DMA,
|
||||
HW_IP_TYPE::UVD,
|
||||
HW_IP_TYPE::VCE,
|
||||
HW_IP_TYPE::UVD_ENC,
|
||||
HW_IP_TYPE::VCN_DEC,
|
||||
HW_IP_TYPE::VCN_ENC,
|
||||
HW_IP_TYPE::VCN_JPEG,
|
||||
HW_IP_TYPE::VPE,
|
||||
];
|
||||
|
||||
pub struct AmdGpuController {
|
||||
handle: GpuHandle,
|
||||
drm_handle: Option<DrmHandle>,
|
||||
drm_handle: Option<Box<dyn DrmProvider>>,
|
||||
common: CommonControllerInfo,
|
||||
fan_control_handle: RefCell<Option<FanControlHandle>>,
|
||||
last_drm_util: RefCell<Option<DrmUtilMap>>,
|
||||
@@ -111,16 +96,24 @@ impl AmdGpuController {
|
||||
let handle = GpuHandle::new_from_path(common.sysfs_path.clone())
|
||||
.map_err(|error| anyhow!("failed to initialize gpu handle: {error}"))?;
|
||||
|
||||
#[allow(unused_mut)]
|
||||
let mut drm_handle = None;
|
||||
#[cfg(not(test))]
|
||||
if let Some(libdrm_amdgpu) = libdrm_amdgpu
|
||||
&& handle.get_driver() == "amdgpu"
|
||||
{
|
||||
drm_handle = Some(
|
||||
get_drm_handle(&common, libdrm_amdgpu).context("Could not get AMD DRM handle")?,
|
||||
);
|
||||
}
|
||||
#[allow(unused_labels)]
|
||||
let drm_handle: Option<Box<dyn DrmProvider>> = 'drm: {
|
||||
#[cfg(feature = "mock")]
|
||||
if let Some(mock) = MockDrmProvider::new(&common.sysfs_path) {
|
||||
break 'drm Some(Box::new(mock) as Box<dyn DrmProvider>);
|
||||
}
|
||||
|
||||
if let Some(libdrm_amdgpu) = libdrm_amdgpu
|
||||
&& handle.get_driver() == "amdgpu"
|
||||
&& !cfg!(test)
|
||||
{
|
||||
let handle = AmdGpuDrmProvider::new(&common, libdrm_amdgpu)
|
||||
.context("Could not get AMD DRM handle")?;
|
||||
Some(Box::new(handle))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
|
||||
Ok(Self {
|
||||
handle,
|
||||
@@ -526,8 +519,7 @@ impl AmdGpuController {
|
||||
let vram_clockspeed = self
|
||||
.drm_handle
|
||||
.as_ref()
|
||||
.and_then(|handle| handle.sensor_info(SENSOR_TYPE::GFX_MCLK).ok())
|
||||
.map(u64::from)
|
||||
.and_then(|handle| handle.get_vram_clock().ok())
|
||||
.or_else(|| self.hw_mon_and_then(HwMon::get_vram_clockspeed));
|
||||
|
||||
let mut sensors = IndexMap::new();
|
||||
@@ -577,8 +569,6 @@ impl AmdGpuController {
|
||||
}
|
||||
|
||||
fn get_drm_info(&self) -> Option<DrmInfo> {
|
||||
use libdrm_amdgpu_sys::AMDGPU::VRAM_TYPE;
|
||||
|
||||
let cache_info = self
|
||||
.kfd_node_path()
|
||||
.inspect(|path| debug!("found KFD node path at '{}'", path.display()))
|
||||
@@ -595,64 +585,8 @@ impl AmdGpuController {
|
||||
trace!("Reading DRM info");
|
||||
let drm_handle = self.drm_handle.as_ref();
|
||||
|
||||
let drm_memory_info =
|
||||
drm_handle
|
||||
.and_then(|handle| handle.memory_info().ok())
|
||||
.map(|memory_info| DrmMemoryInfo {
|
||||
resizeable_bar: Some(memory_info.check_resizable_bar()),
|
||||
cpu_accessible_used: memory_info.cpu_accessible_vram.heap_usage,
|
||||
cpu_accessible_total: memory_info.cpu_accessible_vram.total_heap_size,
|
||||
});
|
||||
|
||||
match drm_handle {
|
||||
Some(handle) => handle.device_info().ok().map(|drm_info| DrmInfo {
|
||||
device_name: drm_info.find_device_name(),
|
||||
pci_revision_id: Some(drm_info.pci_rev_id()),
|
||||
family_name: Some(drm_info.get_family_name().to_string()),
|
||||
family_id: Some(drm_info.family_id()),
|
||||
asic_name: Some(drm_info.get_asic_name().to_string()),
|
||||
chip_class: Some(drm_info.get_chip_class().to_string()),
|
||||
compute_units: Some(drm_info.cu_active_number),
|
||||
isa: drm_info
|
||||
.get_gfx_target_version()
|
||||
.map(|version| version.to_string()),
|
||||
streaming_multiprocessors: None,
|
||||
cuda_cores: None,
|
||||
vram_type: Some(drm_info.get_vram_type().to_string()),
|
||||
vram_vendor: self.handle.get_vram_vendor().ok(),
|
||||
vram_clock_ratio: match drm_info.get_vram_type() {
|
||||
VRAM_TYPE::GDDR6 => 2.0,
|
||||
_ => 1.0,
|
||||
},
|
||||
amd_ip_info: ALL_HW_IP
|
||||
.iter()
|
||||
.filter_map(|ip_type| {
|
||||
let ip_info = handle.get_hw_ip_info(*ip_type).ok()?;
|
||||
|
||||
Some(AmdIpInfo {
|
||||
ip_type: ip_info.ip_type.to_string(),
|
||||
version_major: ip_info.info.hw_ip_version_major,
|
||||
version_minor: ip_info.info.hw_ip_version_minor,
|
||||
queues: ip_info.info.num_queues(),
|
||||
count: ip_info.count,
|
||||
})
|
||||
})
|
||||
.collect(),
|
||||
vram_bit_width: Some(drm_info.vram_bit_width),
|
||||
vram_max_bw: Some(drm_info.peak_memory_bw_gb().to_string()),
|
||||
cache_info,
|
||||
memory_info: drm_memory_info,
|
||||
rop_info: Some(RopInfo {
|
||||
unit_count: drm_info.rb_pipes(),
|
||||
operations_factor: if drm_info.get_asic_name().rbplus_allowed() {
|
||||
8
|
||||
} else {
|
||||
4
|
||||
},
|
||||
operations_count: drm_info.calc_rop_count(),
|
||||
}),
|
||||
intel: IntelDrmInfo::default(),
|
||||
}),
|
||||
Some(drm_handle) => drm_handle.get_drm_info(&self.handle, cache_info),
|
||||
None => Some(DrmInfo {
|
||||
cache_info,
|
||||
vram_clock_ratio: 1.0,
|
||||
@@ -728,10 +662,13 @@ impl AmdGpuController {
|
||||
|
||||
#[cfg(not(test))]
|
||||
fn kfd_node_path(&self) -> Option<PathBuf> {
|
||||
self.drm_handle
|
||||
.as_ref()
|
||||
.and_then(|handle| handle.get_pci_bus_info().ok())
|
||||
.and_then(|bus_info| bus_info.get_drm_render_path().ok())
|
||||
self.common
|
||||
.get_drm_render()
|
||||
.ok()
|
||||
// self.drm_handle
|
||||
// .as_ref()
|
||||
// .and_then(|handle| handle.get_pci_bus_info().ok())
|
||||
// .and_then(|bus_info| bus_info.get_drm_render_path().ok())
|
||||
.and_then(|path| {
|
||||
path.file_name()
|
||||
.and_then(|name| name.to_str())
|
||||
@@ -778,14 +715,8 @@ impl GpuController for AmdGpuController {
|
||||
fn device_type(&self) -> DeviceType {
|
||||
self.drm_handle
|
||||
.as_ref()
|
||||
.and_then(|drm| drm.device_info().ok())
|
||||
.map_or(DeviceType::Dedicated, |info| {
|
||||
if (info.ids_flags & AMDGPU_IDS_FLAGS_FUSION) > 0 {
|
||||
DeviceType::Integrated
|
||||
} else {
|
||||
DeviceType::Dedicated
|
||||
}
|
||||
})
|
||||
.and_then(|drm| drm.get_device_type())
|
||||
.unwrap_or(DeviceType::Dedicated)
|
||||
}
|
||||
|
||||
fn get_info(
|
||||
@@ -850,8 +781,7 @@ impl GpuController for AmdGpuController {
|
||||
fn friendly_name(&self) -> Option<String> {
|
||||
self.drm_handle
|
||||
.as_ref()
|
||||
.and_then(|handle| handle.device_info().ok())
|
||||
.and_then(|info| info.find_device_name())
|
||||
.and_then(|handle| handle.get_device_name())
|
||||
.or_else(|| self.common.pci_info.device_pci_info.model.clone())
|
||||
}
|
||||
|
||||
@@ -1064,12 +994,11 @@ impl GpuController for AmdGpuController {
|
||||
gtt_total_usable: self
|
||||
.drm_handle
|
||||
.as_ref()
|
||||
.and_then(|handle| handle.vram_gtt_info().ok())
|
||||
.map(|info| info.gtt_size),
|
||||
.and_then(|handle| handle.get_gtt_size().ok()),
|
||||
gtt_used: self
|
||||
.drm_handle
|
||||
.as_ref()
|
||||
.and_then(|handle| handle.gtt_usage_info().ok()),
|
||||
.and_then(|handle| handle.get_gtt_used().ok()),
|
||||
},
|
||||
power: PowerStats {
|
||||
average: self.hw_mon_and_then(HwMon::get_power_average),
|
||||
@@ -1556,23 +1485,6 @@ impl GpuController for AmdGpuController {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
fn get_drm_handle(
|
||||
common: &CommonControllerInfo,
|
||||
libdrm_amdgpu: &LibDrmAmdgpu,
|
||||
) -> anyhow::Result<DrmHandle> {
|
||||
let path = common.get_drm_render()?;
|
||||
let drm_file = fs::OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.open(&path)
|
||||
.with_context(|| format!("Could not open drm file at {}", path.display()))?;
|
||||
let (handle, _, _) = libdrm_amdgpu
|
||||
.init_device_handle_with_fd(drm_file)
|
||||
.map_err(|err| anyhow!("Could not open drm handle, error code {err}"))?;
|
||||
Ok(handle)
|
||||
}
|
||||
|
||||
fn apply_clocks_config_to_table(
|
||||
config: &ClocksConfiguration,
|
||||
table: &mut ClocksTableGen,
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
pub mod amdgpu;
|
||||
#[cfg(feature = "mock")]
|
||||
pub mod mock;
|
||||
|
||||
use amdgpu_sysfs::gpu_handle::GpuHandle;
|
||||
use lact_schema::{CacheInfo, DeviceType, DrmInfo};
|
||||
use libdrm_amdgpu_sys::AMDGPU::VBIOS::VbiosInfo;
|
||||
|
||||
pub trait DrmProvider {
|
||||
fn get_drm_info(&self, handle: &GpuHandle, cache_info: Option<CacheInfo>) -> Option<DrmInfo>;
|
||||
|
||||
fn get_device_type(&self) -> Option<DeviceType>;
|
||||
|
||||
fn get_gtt_size(&self) -> Result<u64, i32>;
|
||||
|
||||
fn get_gtt_used(&self) -> Result<u64, i32>;
|
||||
|
||||
fn get_vram_clock(&self) -> Result<u64, i32>;
|
||||
|
||||
fn get_vbios_info(&self) -> Result<VbiosInfo, i32>;
|
||||
|
||||
fn get_device_name(&self) -> Option<String>;
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
use super::DrmProvider;
|
||||
use amdgpu_sysfs::gpu_handle::GpuHandle;
|
||||
use anyhow::{Context as _, anyhow};
|
||||
use lact_schema::{AmdIpInfo, CacheInfo, DeviceType, DrmInfo, DrmMemoryInfo, RopInfo};
|
||||
use libdrm_amdgpu_sys::{
|
||||
AMDGPU::{
|
||||
GPU_INFO as _, HW_IP::HW_IP_TYPE, SENSOR_INFO::SENSOR_TYPE, VBIOS::VbiosInfo, VRAM_TYPE,
|
||||
},
|
||||
LibDrmAmdgpu,
|
||||
};
|
||||
use std::fs;
|
||||
use tracing::error;
|
||||
|
||||
const AMDGPU_IDS_FLAGS_FUSION: u64 = 0x1;
|
||||
|
||||
const ALL_HW_IP: &[HW_IP_TYPE] = &[
|
||||
HW_IP_TYPE::GFX,
|
||||
HW_IP_TYPE::COMPUTE,
|
||||
HW_IP_TYPE::DMA,
|
||||
HW_IP_TYPE::UVD,
|
||||
HW_IP_TYPE::VCE,
|
||||
HW_IP_TYPE::UVD_ENC,
|
||||
HW_IP_TYPE::VCN_DEC,
|
||||
HW_IP_TYPE::VCN_ENC,
|
||||
HW_IP_TYPE::VCN_JPEG,
|
||||
HW_IP_TYPE::VPE,
|
||||
];
|
||||
|
||||
use crate::server::gpu_controller::CommonControllerInfo;
|
||||
|
||||
pub struct AmdGpuDrmProvider(libdrm_amdgpu_sys::AMDGPU::DeviceHandle);
|
||||
|
||||
impl AmdGpuDrmProvider {
|
||||
pub fn new(
|
||||
common: &CommonControllerInfo,
|
||||
libdrm_amdgpu: &LibDrmAmdgpu,
|
||||
) -> anyhow::Result<Self> {
|
||||
let path = common.get_drm_render()?;
|
||||
let drm_file = fs::OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.open(&path)
|
||||
.with_context(|| format!("Could not open drm file at {}", path.display()))?;
|
||||
let (handle, _, _) = libdrm_amdgpu
|
||||
.init_device_handle_with_fd(drm_file)
|
||||
.map_err(|err| anyhow!("Could not open drm handle, error code {err}"))?;
|
||||
|
||||
Ok(Self(handle))
|
||||
}
|
||||
}
|
||||
|
||||
impl DrmProvider for AmdGpuDrmProvider {
|
||||
fn get_drm_info(&self, handle: &GpuHandle, cache_info: Option<CacheInfo>) -> Option<DrmInfo> {
|
||||
let drm_memory_info = self.0.memory_info().ok().map(|memory_info| DrmMemoryInfo {
|
||||
resizeable_bar: Some(memory_info.check_resizable_bar()),
|
||||
cpu_accessible_used: memory_info.cpu_accessible_vram.heap_usage,
|
||||
cpu_accessible_total: memory_info.cpu_accessible_vram.total_heap_size,
|
||||
});
|
||||
let drm_info = self
|
||||
.0
|
||||
.device_info()
|
||||
.inspect_err(|err| error!("could not fetch DRM info: {err}"))
|
||||
.ok()?;
|
||||
|
||||
Some(DrmInfo {
|
||||
device_name: drm_info.find_device_name(),
|
||||
pci_revision_id: Some(drm_info.pci_rev_id()),
|
||||
family_name: Some(drm_info.get_family_name().to_string()),
|
||||
family_id: Some(drm_info.family_id()),
|
||||
asic_name: Some(drm_info.get_asic_name().to_string()),
|
||||
chip_class: Some(drm_info.get_chip_class().to_string()),
|
||||
compute_units: Some(drm_info.cu_active_number),
|
||||
isa: drm_info
|
||||
.get_gfx_target_version()
|
||||
.map(|version| version.to_string()),
|
||||
streaming_multiprocessors: None,
|
||||
cuda_cores: None,
|
||||
vram_type: Some(drm_info.get_vram_type().to_string()),
|
||||
vram_vendor: handle.get_vram_vendor().ok(),
|
||||
vram_clock_ratio: match drm_info.get_vram_type() {
|
||||
VRAM_TYPE::GDDR6 => 2.0,
|
||||
_ => 1.0,
|
||||
},
|
||||
amd_ip_info: ALL_HW_IP
|
||||
.iter()
|
||||
.filter_map(|ip_type| {
|
||||
let ip_info = self.0.get_hw_ip_info(*ip_type).ok()?;
|
||||
|
||||
Some(AmdIpInfo {
|
||||
ip_type: ip_info.ip_type.to_string(),
|
||||
version_major: ip_info.info.hw_ip_version_major,
|
||||
version_minor: ip_info.info.hw_ip_version_minor,
|
||||
queues: ip_info.info.num_queues(),
|
||||
count: ip_info.count,
|
||||
})
|
||||
})
|
||||
.collect(),
|
||||
vram_bit_width: Some(drm_info.vram_bit_width),
|
||||
vram_max_bw: Some(drm_info.peak_memory_bw_gb().to_string()),
|
||||
cache_info,
|
||||
memory_info: drm_memory_info,
|
||||
rop_info: Some(RopInfo {
|
||||
unit_count: drm_info.rb_pipes(),
|
||||
operations_factor: if drm_info.get_asic_name().rbplus_allowed() {
|
||||
8
|
||||
} else {
|
||||
4
|
||||
},
|
||||
operations_count: drm_info.calc_rop_count(),
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
}
|
||||
|
||||
fn get_gtt_size(&self) -> Result<u64, i32> {
|
||||
self.0.vram_gtt_info().map(|info| info.gtt_size)
|
||||
}
|
||||
|
||||
fn get_gtt_used(&self) -> Result<u64, i32> {
|
||||
self.0.gtt_usage_info()
|
||||
}
|
||||
|
||||
fn get_vram_clock(&self) -> Result<u64, i32> {
|
||||
self.0.sensor_info(SENSOR_TYPE::GFX_MCLK).map(u64::from)
|
||||
}
|
||||
|
||||
fn get_vbios_info(&self) -> Result<VbiosInfo, i32> {
|
||||
self.0.get_vbios_info()
|
||||
}
|
||||
|
||||
fn get_device_name(&self) -> Option<String> {
|
||||
self.0
|
||||
.device_info()
|
||||
.ok()
|
||||
.and_then(|info| info.find_device_name())
|
||||
}
|
||||
|
||||
fn get_device_type(&self) -> Option<DeviceType> {
|
||||
self.0.device_info().ok().map(|info| {
|
||||
if (info.ids_flags & AMDGPU_IDS_FLAGS_FUSION) > 0 {
|
||||
DeviceType::Integrated
|
||||
} else {
|
||||
DeviceType::Dedicated
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
use super::DrmProvider;
|
||||
use crate::server::handler::SnapshotDeviceInfo;
|
||||
use lact_schema::{DeviceType, DrmInfo};
|
||||
use libdrm_amdgpu_sys::AMDGPU::VBIOS::VbiosInfo;
|
||||
use std::path::Path;
|
||||
use tracing::info;
|
||||
|
||||
pub struct MockDrmProvider {
|
||||
snapshot: SnapshotDeviceInfo,
|
||||
}
|
||||
|
||||
impl MockDrmProvider {
|
||||
pub fn new(sysfs: &Path) -> Option<Self> {
|
||||
let info_path = sysfs.parent()?.parent()?.join("info.json");
|
||||
let raw_snapshot = std::fs::read_to_string(&info_path).ok()?;
|
||||
let snapshot = serde_json::from_str(&raw_snapshot).expect("could not parse snapshot");
|
||||
|
||||
info!("using mock device info from {}", info_path.display());
|
||||
|
||||
Some(Self { snapshot })
|
||||
}
|
||||
}
|
||||
|
||||
impl DrmProvider for MockDrmProvider {
|
||||
fn get_drm_info(
|
||||
&self,
|
||||
_handle: &amdgpu_sysfs::gpu_handle::GpuHandle,
|
||||
cache_info: Option<lact_schema::CacheInfo>,
|
||||
) -> Option<DrmInfo> {
|
||||
self.snapshot
|
||||
.info
|
||||
.drm_info
|
||||
.clone()
|
||||
.map(|info| DrmInfo { cache_info, ..info })
|
||||
}
|
||||
|
||||
fn get_device_type(&self) -> Option<DeviceType> {
|
||||
Some(DeviceType::Dedicated)
|
||||
}
|
||||
|
||||
fn get_gtt_size(&self) -> Result<u64, i32> {
|
||||
self.snapshot.stats.vram.gtt_total_usable.ok_or(-1)
|
||||
}
|
||||
|
||||
fn get_gtt_used(&self) -> Result<u64, i32> {
|
||||
self.snapshot.stats.vram.gtt_used.ok_or(-1)
|
||||
}
|
||||
|
||||
fn get_vram_clock(&self) -> Result<u64, i32> {
|
||||
self.snapshot.stats.clockspeed.vram_clockspeed.ok_or(-1)
|
||||
}
|
||||
|
||||
fn get_vbios_info(&self) -> Result<VbiosInfo, i32> {
|
||||
Err(-1)
|
||||
}
|
||||
|
||||
fn get_device_name(&self) -> Option<String> {
|
||||
self.snapshot
|
||||
.info
|
||||
.drm_info
|
||||
.as_ref()
|
||||
.and_then(|info| info.device_name.clone())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
---
|
||||
source: lact-daemon/src/tests/mod.rs
|
||||
expression: device_info
|
||||
---
|
||||
{
|
||||
"clocks_info": {
|
||||
"max_sclk": 2200,
|
||||
"table": {
|
||||
"type": "amd",
|
||||
"value": {
|
||||
"data": {
|
||||
"current_mclk_range": {
|
||||
"max": null,
|
||||
"min": null
|
||||
},
|
||||
"current_sclk_range": {
|
||||
"max": 2200,
|
||||
"min": 600
|
||||
},
|
||||
"od_range": {
|
||||
"curve_sclk_points": [],
|
||||
"curve_voltage_points": [],
|
||||
"mclk": null,
|
||||
"sclk": {
|
||||
"max": 2200,
|
||||
"min": 600
|
||||
},
|
||||
"sclk_offset": null,
|
||||
"voltage_offset": null
|
||||
},
|
||||
"sclk_offset": null,
|
||||
"vddc_curve": [],
|
||||
"voltage_offset": null
|
||||
},
|
||||
"kind": "rdna"
|
||||
}
|
||||
}
|
||||
},
|
||||
"info": {
|
||||
"driver": "amdgpu",
|
||||
"drm_info": {
|
||||
"amd_ip_info": [
|
||||
{
|
||||
"count": 1,
|
||||
"ip_type": "GFX",
|
||||
"queues": 1,
|
||||
"version_major": 10,
|
||||
"version_minor": 0
|
||||
},
|
||||
{
|
||||
"count": 1,
|
||||
"ip_type": "COMPUTE",
|
||||
"queues": 4,
|
||||
"version_major": 10,
|
||||
"version_minor": 0
|
||||
},
|
||||
{
|
||||
"count": 1,
|
||||
"ip_type": "DMA",
|
||||
"queues": 1,
|
||||
"version_major": 5,
|
||||
"version_minor": 2
|
||||
},
|
||||
{
|
||||
"count": 1,
|
||||
"ip_type": "VCN_DEC",
|
||||
"queues": 1,
|
||||
"version_major": 3,
|
||||
"version_minor": 0
|
||||
},
|
||||
{
|
||||
"count": 1,
|
||||
"ip_type": "VCN_ENC",
|
||||
"queues": 1,
|
||||
"version_major": 3,
|
||||
"version_minor": 0
|
||||
},
|
||||
{
|
||||
"count": 1,
|
||||
"ip_type": "VCN_JPEG",
|
||||
"queues": 1,
|
||||
"version_major": 3,
|
||||
"version_minor": 0
|
||||
}
|
||||
],
|
||||
"asic_name": "GFX1036/Raphael/Mendocino/Granite Ridge",
|
||||
"chip_class": "GFX10_3",
|
||||
"compute_units": 2,
|
||||
"family_id": 149,
|
||||
"family_name": "GC 10.3.6",
|
||||
"isa": "gfx1036",
|
||||
"memory_info": {
|
||||
"cpu_accessible_total": 536870912,
|
||||
"cpu_accessible_used": 30269440,
|
||||
"resizeable_bar": true
|
||||
},
|
||||
"pci_revision_id": 201,
|
||||
"rop_info": {
|
||||
"operations_count": 8,
|
||||
"operations_factor": 8,
|
||||
"unit_count": 1
|
||||
},
|
||||
"vram_bit_width": 128,
|
||||
"vram_clock_ratio": 1.0,
|
||||
"vram_max_bw": "96",
|
||||
"vram_type": "DDR5"
|
||||
},
|
||||
"flags": [
|
||||
"DumpableVBios",
|
||||
"HasPmfw"
|
||||
],
|
||||
"link_info": {
|
||||
"current_speed": "16.0 GT/s PCIe",
|
||||
"current_width": "16",
|
||||
"max_speed": "16.0 GT/s PCIe",
|
||||
"max_width": "16"
|
||||
},
|
||||
"pci_info": {
|
||||
"device_pci_info": {
|
||||
"model": "Granite Ridge [Radeon Graphics]",
|
||||
"model_id": "13C0",
|
||||
"vendor": "Advanced Micro Devices, Inc. [AMD/ATI]",
|
||||
"vendor_id": "1002"
|
||||
},
|
||||
"subsystem_pci_info": {
|
||||
"model_id": "7E56",
|
||||
"vendor": "Micro-Star International Co., Ltd. [MSI]",
|
||||
"vendor_id": "1462"
|
||||
}
|
||||
},
|
||||
"vbios_version": "102-RAPHAEL-008",
|
||||
"vulkan_instances": []
|
||||
},
|
||||
"pci_info": {
|
||||
"device_pci_info": {
|
||||
"model": "Granite Ridge [Radeon Graphics]",
|
||||
"model_id": "13C0",
|
||||
"vendor": "Advanced Micro Devices, Inc. [AMD/ATI]",
|
||||
"vendor_id": "1002"
|
||||
},
|
||||
"subsystem_pci_info": {
|
||||
"model_id": "7E56",
|
||||
"vendor": "Micro-Star International Co., Ltd. [MSI]",
|
||||
"vendor_id": "1462"
|
||||
}
|
||||
},
|
||||
"power_profile_modes": null,
|
||||
"power_states": {
|
||||
"core": [
|
||||
{
|
||||
"enabled": true,
|
||||
"id": {
|
||||
"Index": 0
|
||||
},
|
||||
"value": 600
|
||||
},
|
||||
{
|
||||
"enabled": true,
|
||||
"id": {
|
||||
"Index": 1
|
||||
},
|
||||
"value": 700
|
||||
},
|
||||
{
|
||||
"enabled": true,
|
||||
"id": {
|
||||
"Index": 2
|
||||
},
|
||||
"value": 2200
|
||||
}
|
||||
],
|
||||
"vram": [
|
||||
{
|
||||
"enabled": true,
|
||||
"id": {
|
||||
"Index": 0
|
||||
},
|
||||
"value": 3000
|
||||
}
|
||||
]
|
||||
},
|
||||
"stats": {
|
||||
"active_power_states": {
|
||||
"core": {
|
||||
"Index": 2
|
||||
},
|
||||
"memory": {
|
||||
"Index": 0
|
||||
}
|
||||
},
|
||||
"busy_percent": 5,
|
||||
"clockspeed": {
|
||||
"gpu_clockspeed": 2200,
|
||||
"sensors": {},
|
||||
"vram_clockspeed": 3000
|
||||
},
|
||||
"fan": {
|
||||
"control_enabled": false,
|
||||
"pmfw_info": {}
|
||||
},
|
||||
"performance_level": "auto",
|
||||
"power": {
|
||||
"current": 0.064,
|
||||
"sensors": {
|
||||
"gfx": 22.506,
|
||||
"soc": 16.8
|
||||
}
|
||||
},
|
||||
"temps": {
|
||||
"edge": {
|
||||
"crit": null,
|
||||
"crit_hyst": null,
|
||||
"current": 46.0,
|
||||
"display_only": false,
|
||||
"primary": true
|
||||
},
|
||||
"soc": {
|
||||
"crit": null,
|
||||
"crit_hyst": null,
|
||||
"current": 49.0,
|
||||
"display_only": true,
|
||||
"primary": false
|
||||
}
|
||||
},
|
||||
"throttle_info": {
|
||||
"Current": [
|
||||
"EDC_CPU"
|
||||
]
|
||||
},
|
||||
"voltage": {
|
||||
"gpu": 1375,
|
||||
"sensors": {
|
||||
"northbridge": 1199
|
||||
}
|
||||
},
|
||||
"vram": {
|
||||
"gtt_total_usable": 33110503424,
|
||||
"gtt_used": 25473024,
|
||||
"total": 536870912,
|
||||
"used": 30269440
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
226:2
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
0x030000
|
||||
@@ -0,0 +1 @@
|
||||
queue full
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
44
|
||||
@@ -0,0 +1 @@
|
||||
16.0 GT/s PCIe
|
||||
@@ -0,0 +1 @@
|
||||
16
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1 @@
|
||||
0x13c0
|
||||
@@ -0,0 +1 @@
|
||||
44
|
||||
@@ -0,0 +1 @@
|
||||
(null)
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
0x21000115
|
||||
@@ -0,0 +1 @@
|
||||
0x00000003
|
||||
@@ -0,0 +1 @@
|
||||
0x05003300
|
||||
@@ -0,0 +1 @@
|
||||
0x0000000e
|
||||
@@ -0,0 +1 @@
|
||||
0x0000001c
|
||||
@@ -0,0 +1 @@
|
||||
0x0000001c
|
||||
@@ -0,0 +1 @@
|
||||
0x00000012
|
||||
@@ -0,0 +1 @@
|
||||
0x00000020
|
||||
@@ -0,0 +1 @@
|
||||
0x00000001
|
||||
@@ -0,0 +1 @@
|
||||
0x00000001
|
||||
@@ -0,0 +1 @@
|
||||
0x00000001
|
||||
@@ -0,0 +1 @@
|
||||
0x00000009
|
||||
@@ -0,0 +1 @@
|
||||
0x00625400
|
||||
@@ -0,0 +1 @@
|
||||
0x04121015
|
||||
@@ -0,0 +1 @@
|
||||
queue full
|
||||
@@ -0,0 +1 @@
|
||||
5
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
2200000000
|
||||
@@ -0,0 +1 @@
|
||||
sclk
|
||||
@@ -0,0 +1 @@
|
||||
1375
|
||||
@@ -0,0 +1 @@
|
||||
vddgfx
|
||||
@@ -0,0 +1 @@
|
||||
1199
|
||||
@@ -0,0 +1 @@
|
||||
vddnb
|
||||
@@ -0,0 +1 @@
|
||||
amdgpu
|
||||
@@ -0,0 +1 @@
|
||||
auto
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
unsupported
|
||||
+1
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
64000
|
||||
@@ -0,0 +1 @@
|
||||
PPT
|
||||
@@ -0,0 +1 @@
|
||||
46000
|
||||
@@ -0,0 +1 @@
|
||||
edge
|
||||
Whitespace-only changes.
@@ -0,0 +1,5 @@
|
||||
0x00016000
|
||||
0x00DC0000
|
||||
0x00E00000
|
||||
0x00E40000
|
||||
0x0243FC00
|
||||
@@ -0,0 +1 @@
|
||||
0x0
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1 @@
|
||||
13
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
+1
@@ -0,0 +1 @@
|
||||
5
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
5
|
||||
@@ -0,0 +1,6 @@
|
||||
0x00000000
|
||||
0x00000014
|
||||
0x00000D20
|
||||
0x00010400
|
||||
0x0241B000
|
||||
0x04040000
|
||||
@@ -0,0 +1 @@
|
||||
0x0
|
||||
@@ -0,0 +1 @@
|
||||
108
|
||||
@@ -0,0 +1 @@
|
||||
7
|
||||
@@ -0,0 +1 @@
|
||||
3
|
||||
+1
@@ -0,0 +1 @@
|
||||
6
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1,3 @@
|
||||
0x00001260
|
||||
0x0000A000
|
||||
0x02402C00
|
||||
@@ -0,0 +1 @@
|
||||
0x0
|
||||
@@ -0,0 +1 @@
|
||||
11
|
||||
@@ -0,0 +1 @@
|
||||
10
|
||||
@@ -0,0 +1 @@
|
||||
3
|
||||
+1
@@ -0,0 +1 @@
|
||||
3
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
6
|
||||
@@ -0,0 +1,3 @@
|
||||
0x00007800
|
||||
0x00007E00
|
||||
0x02403000
|
||||
@@ -0,0 +1 @@
|
||||
0x0
|
||||
@@ -0,0 +1 @@
|
||||
12
|
||||
@@ -0,0 +1 @@
|
||||
3
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
+1
@@ -0,0 +1 @@
|
||||
3
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
2
|
||||
@@ -0,0 +1,2 @@
|
||||
0x00480000
|
||||
0x02403800
|
||||
@@ -0,0 +1 @@
|
||||
0x0
|
||||
@@ -0,0 +1 @@
|
||||
14
|
||||
@@ -0,0 +1 @@
|
||||
6
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
+1
@@ -0,0 +1 @@
|
||||
2
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1,2 @@
|
||||
0x00014000
|
||||
0x02425800
|
||||
@@ -0,0 +1 @@
|
||||
0x0
|
||||
@@ -0,0 +1 @@
|
||||
150
|
||||
@@ -0,0 +1 @@
|
||||
9
|
||||
@@ -0,0 +1 @@
|
||||
5
|
||||
Loaded 100 of 367 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user