From efcbbb75df5c9bc79b71414f77c9445453f27037 Mon Sep 17 00:00:00 2001 From: pdapandapda Date: Tue, 26 Aug 2025 16:40:04 +0800 Subject: [PATCH 1/9] Update gpu_fdinfo.cpp to fix panthor drm driver --- src/gpu_fdinfo.cpp | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/gpu_fdinfo.cpp b/src/gpu_fdinfo.cpp index 84b5451ce4..b9c0066500 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() @@ -115,6 +116,8 @@ uint64_t GPU_fdinfo::get_gpu_time() if (module == "panfrost") return get_gpu_time_panfrost(); + if (module == "panthor") + return get_gpu_time_panthor(); for (auto& fd : fdinfo_data) { auto time = fd[drm_engine_type]; @@ -145,6 +148,18 @@ uint64_t GPU_fdinfo::get_gpu_time_panfrost() { return total; } +uint64_t GPU_fdinfo::get_gpu_time_panthor() { + uint64_t total = 0; + for (auto& fd : fdinfo_data) { + auto time = fd["drm-engine-panthor"]; + + if (!time.empty()) + total += std::stoull(time); + } + + return total; +} + float GPU_fdinfo::get_memory_used() { uint64_t total = 0; @@ -168,7 +183,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 +544,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 +563,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 +623,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; From ee2cb5bd8aac97dd0b6d3cbdb184f12b3a070fde Mon Sep 17 00:00:00 2001 From: pdapandapda Date: Tue, 26 Aug 2025 16:42:28 +0800 Subject: [PATCH 2/9] Update gpu_fdinfo.h to fix panthor drm driver --- src/gpu_fdinfo.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gpu_fdinfo.h b/src/gpu_fdinfo.h index 7d22703b40..5b0c14b9a1 100644 --- a/src/gpu_fdinfo.h +++ b/src/gpu_fdinfo.h @@ -98,6 +98,10 @@ class GPU_fdinfo { uint64_t get_gpu_time_panfrost(); int get_gpu_clock_panfrost(); + // add panthor function declaration + uint64_t get_gpu_time_panthor(); + int get_gpu_clock_panthor(); + std::ifstream throttle_status_stream; std::vector throttle_power_streams; std::vector throttle_current_streams; @@ -150,6 +154,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 && From 59970c85555da4de2b644899fed1cb8e11a2fb36 Mon Sep 17 00:00:00 2001 From: pdapandapda Date: Tue, 26 Aug 2025 16:43:20 +0800 Subject: [PATCH 3/9] Update gpu.h to fix panthor drm driver --- src/gpu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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" }; }; From ba5e0324ac6a00967f9be1c62c350397c969c0b2 Mon Sep 17 00:00:00 2001 From: pdapandapda Date: Tue, 26 Aug 2025 16:45:19 +0800 Subject: [PATCH 4/9] Update README.md to add panthor information --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e60211b8f2..90713a3c86 100644 --- a/README.md +++ b/README.md @@ -691,3 +691,4 @@ Example output: #### Panfrost notes - GPU usage requires `echo 1 | sudo tee /sys/class/drm/renderD*/device/profiling` +- If your linux kenel is newer than 6.10 and using "Panthor" drm driver,requires `echo 3 | sudo tee /sys/bus/platform/drivers/panthor/[a-f0-9]*.gpu/profiling` From 86da677a0b6840bd1515ec8961ec23dd65890a95 Mon Sep 17 00:00:00 2001 From: pdapandapda Date: Thu, 28 Aug 2025 03:39:27 +0800 Subject: [PATCH 5/9] Update gpu_fdinfo.cpp combine get_gpu_time_panthor into get_gpu_time --- src/gpu_fdinfo.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/gpu_fdinfo.cpp b/src/gpu_fdinfo.cpp index b9c0066500..42a98fc3dd 100644 --- a/src/gpu_fdinfo.cpp +++ b/src/gpu_fdinfo.cpp @@ -116,8 +116,6 @@ uint64_t GPU_fdinfo::get_gpu_time() if (module == "panfrost") return get_gpu_time_panfrost(); - if (module == "panthor") - return get_gpu_time_panthor(); for (auto& fd : fdinfo_data) { auto time = fd[drm_engine_type]; @@ -148,18 +146,6 @@ uint64_t GPU_fdinfo::get_gpu_time_panfrost() { return total; } -uint64_t GPU_fdinfo::get_gpu_time_panthor() { - uint64_t total = 0; - for (auto& fd : fdinfo_data) { - auto time = fd["drm-engine-panthor"]; - - if (!time.empty()) - total += std::stoull(time); - } - - return total; -} - float GPU_fdinfo::get_memory_used() { uint64_t total = 0; From f2f924181cf7cd797c1d7164a2644f9ebd531e9f Mon Sep 17 00:00:00 2001 From: pdapandapda Date: Thu, 28 Aug 2025 03:42:36 +0800 Subject: [PATCH 6/9] delete get_gpu_time_panthor delaration --- src/gpu_fdinfo.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gpu_fdinfo.h b/src/gpu_fdinfo.h index 5b0c14b9a1..a8691c05e0 100644 --- a/src/gpu_fdinfo.h +++ b/src/gpu_fdinfo.h @@ -98,8 +98,6 @@ class GPU_fdinfo { uint64_t get_gpu_time_panfrost(); int get_gpu_clock_panfrost(); - // add panthor function declaration - uint64_t get_gpu_time_panthor(); int get_gpu_clock_panthor(); std::ifstream throttle_status_stream; From ec9781698a2e3d3b814a2dea1e6dbdc179dd20c5 Mon Sep 17 00:00:00 2001 From: pdapandapda Date: Thu, 28 Aug 2025 05:32:40 +0800 Subject: [PATCH 7/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 90713a3c86..f60eb40687 100644 --- a/README.md +++ b/README.md @@ -691,4 +691,4 @@ Example output: #### Panfrost notes - GPU usage requires `echo 1 | sudo tee /sys/class/drm/renderD*/device/profiling` -- If your linux kenel is newer than 6.10 and using "Panthor" drm driver,requires `echo 3 | sudo tee /sys/bus/platform/drivers/panthor/[a-f0-9]*.gpu/profiling` +- If your linux kenel is newer than 6.10 and using "Panthor" drm driver,requires `echo 2 | sudo tee /sys/class/drm/renderD*/device/profiling` From 62cf55da474e8137c1af32bf5573b1d5d3536903 Mon Sep 17 00:00:00 2001 From: pdapandapda Date: Thu, 28 Aug 2025 05:36:02 +0800 Subject: [PATCH 8/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f60eb40687..104444b717 100644 --- a/README.md +++ b/README.md @@ -691,4 +691,4 @@ Example output: #### Panfrost notes - GPU usage requires `echo 1 | sudo tee /sys/class/drm/renderD*/device/profiling` -- If your linux kenel is newer than 6.10 and using "Panthor" drm driver,requires `echo 2 | sudo tee /sys/class/drm/renderD*/device/profiling` +- If your linux kenel is newer than 6.10 and using "Panthor" drm driver,requires `echo 3 | sudo tee /sys/class/drm/renderD*/device/profiling` From f425875191dc96b529f74dc615fcc8d27f0ab3b1 Mon Sep 17 00:00:00 2001 From: pdapandapda Date: Sat, 30 Aug 2025 08:03:45 +0800 Subject: [PATCH 9/9] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 104444b717..2e1bbc2531 100644 --- a/README.md +++ b/README.md @@ -689,6 +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` -- If your linux kenel is newer than 6.10 and using "Panthor" drm driver,requires `echo 3 | 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.