From 26584bf9d1abea2e583cc77fd6ae1f66e3f983cb Mon Sep 17 00:00:00 2001
From: 17314642 <48242771@protonmail.ch>
Date: Mon, 1 Dec 2025 21:25:50 +0300
Subject: [PATCH 1/2] gpu_fdinfo: add panthor driver support
---
README.md | 7 ++++---
src/gpu.h | 7 ++++---
src/gpu_fdinfo.cpp | 17 ++++++++++++-----
src/gpu_fdinfo.h | 5 ++++-
4 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/README.md b/README.md
index de1d5fd342..4fb8c41bf8 100644
--- a/README.md
+++ b/README.md
@@ -551,7 +551,7 @@ Example output:
AMD |
Intel Discrete |
Intel Integrated |
- Panfrost driver |
+ Panfrost/Panthor driver |
|
@@ -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 6f5bd7b231..675d64f8a9 100644
--- a/src/gpu.h
+++ b/src/gpu.h
@@ -43,7 +43,8 @@ class GPU {
amdgpu = std::make_unique(pci_dev, device_id, vendor_id);
if (
- driver == "i915" || driver == "xe" || driver == "panfrost" ||
+ driver == "i915" || driver == "xe" ||
+ driver == "panfrost" || driver == "panthor" ||
driver == "msm_dpu" || driver == "msm_drm"
)
fdinfo = std::make_unique(driver, pci_dev, drm_node);
@@ -199,8 +200,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", "panthor", "msm_dpu", "msm_drm"
};
};
diff --git a/src/gpu_fdinfo.cpp b/src/gpu_fdinfo.cpp
index c2310e1a63..ccf178ea24 100644
--- a/src/gpu_fdinfo.cpp
+++ b/src/gpu_fdinfo.cpp
@@ -168,7 +168,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();
@@ -527,8 +527,8 @@ void GPU_fdinfo::load_xe_i915_throttle_reasons(
int GPU_fdinfo::get_gpu_clock()
{
- if (module == "panfrost")
- return get_gpu_clock_panfrost();
+ if (module == "panfrost" || module == "panthor")
+ return get_gpu_clock_mali();
if (!gpu_clock_stream.is_open())
return 0;
@@ -545,11 +545,18 @@ int GPU_fdinfo::get_gpu_clock()
return std::stoi(clock_str);
}
-int GPU_fdinfo::get_gpu_clock_panfrost() {
+int GPU_fdinfo::get_gpu_clock_mali() {
if (fdinfo_data.empty())
return 0;
- auto freq_str = fdinfo_data[0]["drm-curfreq-fragment"];
+ std::string key;
+
+ if (module == "panfrost")
+ key = "drm-curfreq-fragment";
+ else if (module == "panthor")
+ key = "drm-curfreq-panthor";
+
+ std::string freq_str = fdinfo_data[0][key];
if (freq_str.empty())
return 0;
diff --git a/src/gpu_fdinfo.h b/src/gpu_fdinfo.h
index 7d22703b40..bfa1555d97 100644
--- a/src/gpu_fdinfo.h
+++ b/src/gpu_fdinfo.h
@@ -96,7 +96,7 @@ class GPU_fdinfo {
int get_gpu_clock();
uint64_t get_gpu_time_panfrost();
- int get_gpu_clock_panfrost();
+ int get_gpu_clock_mali();
std::ifstream throttle_status_stream;
std::vector throttle_power_streams;
@@ -150,6 +150,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 = "drm-resident-memory";
}
if (fdinfo_data.size() > 0 &&
From 4ee319ca5b2642f829a7e0fac6e41cdeaceb9fbf Mon Sep 17 00:00:00 2001
From: 17314642 <48242771@protonmail.ch>
Date: Mon, 1 Dec 2025 21:26:51 +0300
Subject: [PATCH 2/2] gpu_fdinfo: add support for units other than KiB in
get_memory_used
---
src/gpu_fdinfo.cpp | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/gpu_fdinfo.cpp b/src/gpu_fdinfo.cpp
index ccf178ea24..0fdd99e836 100644
--- a/src/gpu_fdinfo.cpp
+++ b/src/gpu_fdinfo.cpp
@@ -155,11 +155,20 @@ float GPU_fdinfo::get_memory_used()
if (mem.empty())
continue;
- total += std::stoull(mem);
+ std::string unit = mem.substr(mem.rfind(" ") + 1);
+ uint64_t val = std::stoull(mem);
+
+ if (unit == "KiB")
+ val *= 1024;
+ else if (unit == "MiB")
+ val *= 1024 * 1024;
+ else if (unit == "GiB")
+ val *= 1024 * 1024 * 1024;
+
+ total += val;
}
- // TODO: sometimes it's not KB, so add a check for that.
- return static_cast(total) / 1024 / 1024;
+ return static_cast(total) / 1024 / 1024 / 1024;
}
void GPU_fdinfo::find_hwmon_sensors()