Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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/bus/platform/drivers/panthor/[a-f0-9]*.gpu/profiling`

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.

is this 100% needed? are there no profiling file inside /sys/class/drm/renderD*/device like with panfrost?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

echo 1 | sudo tee /sys/class/drm/renderD*/device/profiling would not work with panthor, official document shows the new address https://docs.kernel.org/gpu/panthor.html

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.

echo <N> > /sys/bus/platform/drivers/panthor/[a-f0-9]*.gpu/profiling
echo <N> > /sys/bus/platform/drivers/panfrost/[a-f0-9]*.gpu/profiling

Are you sure?
https://docs.kernel.org/gpu/panfrost.html

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.

To me it seems like two identical file paths, except driver names.

Only thing that might've changed is the value that you should write inside that file

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not working with my rk3588 at least.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

echo 3 | sudo tee /sys/class/drm/renderD*/device/profiling

works

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
37 changes: 35 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 @@ -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];
Expand Down Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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;

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

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