opnsense-ports/lang/intel-compute-runtime/files/patch-max_freq
Franco Fichtner 358f59d866 */*: sync with upstream
Taken from: HardenedBSD
2020-01-31 13:33:41 +01:00

44 lines
1.2 KiB
Text

/sys/bus/pci/devices doesn't exist as kms-drm exports sysfs via sysctl
$ clinfo | fgrep clock
Max clock frequency 0MHz
--- core/os_interface/linux/drm_neo.cpp.orig 2020-01-23 10:09:13 UTC
+++ core/os_interface/linux/drm_neo.cpp
@@ -18,6 +18,11 @@
#include <cstring>
#include <fstream>
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#endif
+
namespace NEO {
const char *Drm::sysFsDefaultGpuPath = "/drm/card0";
@@ -68,6 +73,16 @@ int Drm::getEnabledPooledEu(int &enabled) {
int Drm::getMaxGpuFrequency(int &maxGpuFrequency) {
maxGpuFrequency = 0;
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ char max_freq[PAGE_SIZE];
+ size_t len = sizeof(max_freq);
+
+ if (sysctlbyname("sys.class.drm.card0.gt_max_freq_mhz", &max_freq, &len, NULL, 0)) {
+ return 0;
+ }
+
+ maxGpuFrequency = std::stoi(max_freq);
+#else
int deviceID = 0;
int ret = getDeviceID(deviceID);
if (ret != 0) {
@@ -89,6 +104,7 @@ int Drm::getMaxGpuFrequency(int &maxGpuFrequency) {
ifs >> maxGpuFrequency;
ifs.close();
+#endif
return 0;
}