Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -691,3 +691,4 @@ Example output:

#### Panfrost notes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just write this:

#### 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.

- 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`
6 changes: 3 additions & 3 deletions src/gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<GPU_fdinfo>(driver, pci_dev, drm_node);
}
Expand Down Expand Up @@ -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<std::string, 7> supported_drivers = {
"amdgpu", "nvidia", "i915", "xe", "panfrost", "msm_dpu", "msm_drm"
const std::array<std::string, 8> supported_drivers = {
"amdgpu", "nvidia", "i915", "xe", "panfrost", "msm_dpu", "msm_drm", "panthor"
};
};

Expand Down
23 changes: 21 additions & 2 deletions src/gpu_fdinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "hud_elements.h"
#endif

#include <fstream>
namespace fs = ghc::filesystem;

void GPU_fdinfo::find_fd()
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
5 changes: 5 additions & 0 deletions src/gpu_fdinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::ifstream> throttle_power_streams;
std::vector<std::ifstream> throttle_current_streams;
Expand Down Expand Up @@ -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 &&
Expand Down