-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add configurable gpu thermal zone #89
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR!
This review is a bit more pedantic, since I want the config variables to behave consistent. I hope you understand :)
Some general points:
- Can you make the config variable relative to
/sys/class/drm/<card>/
? (Since there is already a selector for the specific card) - The config variable + documentation is missing from
data/config
src/AMDGPU.h
Outdated
@@ -40,13 +39,20 @@ namespace AMDGPU | |||
|
|||
inline uint32_t GetTemperature() | |||
{ | |||
if (!RuntimeConfig::Get().hasAMD) | |||
if (!RuntimeConfig::Get().hasAMD && Config::Get().gpuThermalZone.empty()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The additional check shouldn't be here (The check is only intended to fail if AMDGPU is disabled and this method is still called, meaning a developer error)
src/Config.cpp
Outdated
@@ -252,6 +252,7 @@ void Config::Load(const std::string& overrideConfigLocation) | |||
AddConfigVar("WidgetsRight", config.widgetsRight, lineView, foundProperty); | |||
|
|||
AddConfigVar("CPUThermalZone", config.cpuThermalZone, lineView, foundProperty); | |||
AddConfigVar("GPUThermalZone", config.gpuThermalZone, lineView, foundProperty); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name should incorporate that this is only for AMD GPUs, so there is no confusion whether you actually need to set it. I'd suggest "AmdGPUThermalZone"
module.nix
Outdated
@@ -38,6 +38,11 @@ in { | |||
default = "/sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon2/temp1_input"; | |||
description = "path to the cpu thermal sensor, probably something in /sys/device"; | |||
}; | |||
GPUThermalZone = mkOption { | |||
type = types.nullOr types.str; | |||
default = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing default. Please use the old value("device/hwmon/hwmon1/temp1_input") for backwards compatibility.
module.nix
Outdated
GPUThermalZone = mkOption { | ||
type = types.nullOr types.str; | ||
default = ""; | ||
description = "path to the gpu thermal sensor, probably something in /sys/device"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also mention here that this is AMD specific and that the path is relative to /sys/class/drm/<card>/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah lol I totally forgot about nvidia
src/AMDGPU.h
Outdated
@@ -10,8 +10,7 @@ namespace AMDGPU | |||
static const char* utilizationFile = "/device/gpu_busy_percent"; | |||
static const char* vramTotalFile = "/device/mem_info_vram_total"; | |||
static const char* vramUsedFile = "/device/mem_info_vram_used"; | |||
// TODO: Make this configurable | |||
static const char* tempFile = "/sys/class/drm/card0/device/hwmon/hwmon1/temp1_input"; | |||
static const char* tempFile = "/device/hwmon/hwmon0/temp1_input"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed when the config variable has a default.
src/AMDGPU.h
Outdated
file.open(Config::Get().gpuThermalZone); | ||
} else { | ||
file.open(drmCardPrefix + Config::Get().drmAmdCard + tempFile); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fallback code is not needed, when the gpuThermalZone has a default.
src/Config.h
Outdated
@@ -14,6 +14,7 @@ class Config | |||
"VRAM", "GPU", "RAM", "CPU", "Battery", "Power"}; | |||
|
|||
std::string cpuThermalZone = ""; // idk, no standard way of doing this. | |||
std::string gpuThermalZone = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put the default value (The old one, same as comment in module.nix) here (Also for backwards compatibility)
Yeah for sure. I wasn't sure if that was how you wanted it done since it would be a little different than setting a CPU thermal zone (since for that we set a full path instead of a partial). To remove this difference between gpu/cpu's It might be worth changing things to only use full paths instead of setting the For example we could have config options for
Removing the need for setting an explicit This would make things more inline with how things are set for the CPU. Let me know what you think, otherwise I can move forward with the points above (: |
Hmm, good points. I've thought about it a little and I think I still prefer relative paths, though:
|
Yeah sounds good, using relative paths is good for now, I'll get this updated to use them. It might be worth at some point looking into using a dependency or library that handles these queries in the future, or looking at what other bars/widgets do to solve this, not that it is that big of a deal haha. |
Last thing missing now is an entry in |
@@ -32,6 +32,13 @@ WidgetsRight: [Tray, Packages, Audio, Bluetooth, Network, Disk, VRAM, GPU, RAM, | |||
# The CPU sensor to use | |||
CPUThermalZone: /sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon2/temp1_input | |||
|
|||
# The card to poll when using AMDGPU. If you don't have an AMD card, you can skip this config. | |||
# Possible values can be found by querying /sys/class/drm | |||
DrmAmdCard: card0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this option above to make it easier for a new user to understand the AmdGpuThermalZone comment
LGTM, thanks! |
I noticed a bug where the
tempFile
was the entire path (instead of just the subpath) leading to some issues. So I fixed that and also added an option to set the entire path via the config since I'm not sure if the path will be the same for everyone.If the path:
device/hwmon/hwmon0/temp1_input
won't change across machines then the configuration addition probably isn't needed since you can configure the card.