diff --git a/README.md b/README.md index e60211b8f2..2e1bbc2531 100644 --- a/README.md +++ b/README.md @@ -689,5 +689,6 @@ Example output: - GPU usage and memory usage shows usage of current process, not total system usage (it's an issue on intel's side) - Integrated Intel GPUs are **limited** due to lack of hwmon interface (it's an issue on intel's side, [i915 source](https://github.com/torvalds/linux/blob/5fc31936081919a8572a3d644f3fbb258038f337/drivers/gpu/drm/i915/i915_hwmon.c#L914-L916), [xe source](https://github.com/torvalds/linux/blob/5fc31936081919a8572a3d644f3fbb258038f337/drivers/gpu/drm/xe/xe_hwmon.c#L824-L826)) -#### Panfrost notes -- GPU usage requires `echo 1 | sudo tee /sys/class/drm/renderD*/device/profiling` +#### Panfrost and Panthor notes +- GPU usage requires `echo N | sudo tee /sys/class/drm/renderD*/device/profiling` + - Where N is a number, 1 for panfrost and 3 for panthor. diff --git a/src/gpu.h b/src/gpu.h index 91472ec2a0..dd46de96a1 100644 --- a/src/gpu.h +++ b/src/gpu.h @@ -44,7 +44,7 @@ class GPU { if ( driver == "i915" || driver == "xe" || driver == "panfrost" || - driver == "msm_dpu" || driver == "msm_drm" + driver == "msm_dpu" || driver == "msm_drm" || driver == "panthor" ) fdinfo = std::make_unique(driver, pci_dev, drm_node); } @@ -202,8 +202,8 @@ class GPUS { std::string get_pci_device_address(const std::string& drm_card_path); std::string get_driver(const std::string& node); - const std::array supported_drivers = { - "amdgpu", "nvidia", "i915", "xe", "panfrost", "msm_dpu", "msm_drm" + const std::array supported_drivers = { + "amdgpu", "nvidia", "i915", "xe", "panfrost", "msm_dpu", "msm_drm", "panthor" }; }; diff --git a/src/gpu_fdinfo.cpp b/src/gpu_fdinfo.cpp index 84b5451ce4..42a98fc3dd 100644 --- a/src/gpu_fdinfo.cpp +++ b/src/gpu_fdinfo.cpp @@ -4,6 +4,7 @@ #include "hud_elements.h" #endif +#include namespace fs = ghc::filesystem; void GPU_fdinfo::find_fd() @@ -168,7 +169,7 @@ void GPU_fdinfo::find_hwmon_sensors() if (module == "msm") hwmon = find_hwmon_sensor_dir("gpu"); - else if (module == "panfrost") + else if (module == "panfrost" || module == "panthor") hwmon = find_hwmon_sensor_dir("gpu_thermal"); else hwmon = find_hwmon_dir(); @@ -529,7 +530,10 @@ int GPU_fdinfo::get_gpu_clock() { if (module == "panfrost") return get_gpu_clock_panfrost(); - + + if (module == "panthor") + return get_gpu_clock_panthor(); + if (!gpu_clock_stream.is_open()) return 0; @@ -545,6 +549,20 @@ int GPU_fdinfo::get_gpu_clock() return std::stoi(clock_str); } +int GPU_fdinfo::get_gpu_clock_panthor() { + if (fdinfo_data.empty()) + return 0; + + auto freq_str = fdinfo_data[0]["drm-curfreq-panthor"]; + + if (freq_str.empty()) + return 0; + + float freq = std::stoull(freq_str) / 1'000'000; + + return std::round(freq); +} + int GPU_fdinfo::get_gpu_clock_panfrost() { if (fdinfo_data.empty()) return 0; @@ -591,6 +609,7 @@ int GPU_fdinfo::get_throttling_status() check_throttle_reasons(throttle_current_streams) * GPU_throttle_status::CURRENT + check_throttle_reasons(throttle_temp_streams) * GPU_throttle_status::TEMP; // No throttle reasons for OTHER currently + if (reasons == 0) reasons |= GPU_throttle_status::OTHER; diff --git a/src/gpu_fdinfo.h b/src/gpu_fdinfo.h index 7d22703b40..a8691c05e0 100644 --- a/src/gpu_fdinfo.h +++ b/src/gpu_fdinfo.h @@ -98,6 +98,8 @@ class GPU_fdinfo { uint64_t get_gpu_time_panfrost(); int get_gpu_clock_panfrost(); + int get_gpu_clock_panthor(); + std::ifstream throttle_status_stream; std::vector throttle_power_streams; std::vector throttle_current_streams; @@ -150,6 +152,9 @@ class GPU_fdinfo { } else if (module == "panfrost") { drm_engine_type = "drm-engine-fragment"; drm_memory_type = "drm-resident-memory"; + } else if (module == "panthor") { + drm_engine_type = "drm-engine-panthor"; + drm_memory_type = "panthor-resident-memory"; } if (fdinfo_data.size() > 0 &&