Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve GPU debug reports #7456

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
33 changes: 22 additions & 11 deletions src/debug/HyprCtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include <sys/poll.h>
#include <filesystem>
#include <ranges>
#include <fcntl.h>
#include <xf86drm.h>
#include <xf86drmMode.h>

#include <sstream>
#include <string>
Expand Down Expand Up @@ -920,17 +923,25 @@ std::string systemInfoRequest(eHyprCtlOutputFormat format, std::string request)

result += "\n\n";

#if defined(__DragonFly__) || defined(__FreeBSD__)
const std::string GPUINFO = execAndGet("pciconf -lv | fgrep -A4 vga");
#elif defined(__arm__) || defined(__aarch64__)
const std::string GPUINFO = execAndGet("cat /proc/device-tree/soc*/gpu*/compatible");
#else
const std::string GPUINFO = execAndGet("lspci -vnn | grep VGA");
#endif
result += "GPU information: \n" + GPUINFO;
if (GPUINFO.contains("NVIDIA") && std::filesystem::exists("/proc/driver/nvidia/version"))
result += execAndGet("cat /proc/driver/nvidia/version | grep NVRM");
result += "\n\n";
int fd = open("/dev/dri/card0", O_RDONLY | O_CLOEXEC);
Copy link
Member

Choose a reason for hiding this comment

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

this is dumb, we may not even be running on card0. You should get the card(s) path(s) from the current aq session g_pCompositor->m_pAqBackend->session

if (fd > 0) {
drmVersion* version = drmGetVersion(fd);

const std::string name = version->name ? version->name : "Unknown";
const std::string description = version->desc ? version->desc : "Unknown";
std::string GPUINFO = "GPU information:\n";
GPUINFO += "GPU Type: " + name + "\n";
GPUINFO += "Driver Description: " + description + "\n";

result += GPUINFO;
drmFreeVersion(version);
close(fd);

if (GPUINFO.contains("NVIDIA") && std::filesystem::exists("/proc/driver/nvidia/version"))
result += execAndGet("cat /proc/driver/nvidia/version | grep NVRM");

result += "\n\n";
}

result += "os-release: " + execAndGet("cat /etc/os-release") + "\n\n";

Expand Down
28 changes: 18 additions & 10 deletions src/helpers/MiscFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <fcntl.h>
#include <iomanip>
#include <sstream>
#include <xf86drm.h>
#include <xf86drmMode.h>
#ifdef HAS_EXECINFO
#include <execinfo.h>
#endif
Expand Down Expand Up @@ -609,17 +611,23 @@ void logSystemInfo() {

Debug::log(NONE, "\n");

#if defined(__DragonFly__) || defined(__FreeBSD__)
const std::string GPUINFO = execAndGet("pciconf -lv | fgrep -A4 vga");
#elif defined(__arm__) || defined(__aarch64__)
const std::string GPUINFO = execAndGet("cat /proc/device-tree/soc*/gpu*/compatible");
#else
const std::string GPUINFO = execAndGet("lspci -vnn | grep VGA");
#endif
Debug::log(LOG, "GPU information:\n{}\n", GPUINFO);
int fd = open("/dev/dri/card0", O_RDONLY | O_CLOEXEC);
Copy link
Member

Choose a reason for hiding this comment

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

same stuff here, also why are you duping code? make this into a function? renderer does the same, btw, idk why this is needed here

if (fd > 0) {
drmVersion* version = drmGetVersion(fd);

const std::string name = version->name ? version->name : "Unknown";
const std::string description = version->desc ? version->desc : "Unknown";
std::string GPUINFO = "GPU information:\n";
GPUINFO += "GPU Type: " + name + "\n";
GPUINFO += "Driver Description: " + description + "\n";

if (GPUINFO.contains("NVIDIA")) {
Debug::log(WARN, "Warning: you're using an NVIDIA GPU. Make sure you follow the instructions on the wiki if anything is amiss.\n");
Debug::log(LOG, "{}\n", GPUINFO);
drmFreeVersion(version);
close(fd);

if (GPUINFO.contains("NVIDIA")) {
Debug::log(WARN, "Warning: you're using an NVIDIA GPU. Make sure you follow the instructions on the wiki if anything is amiss.\n");
}
}

// log etc
Expand Down
Loading