summaryrefslogtreecommitdiff
path: root/lang/intel-compute-runtime/files/patch-max_freq
blob: eb5239cf2649475dbd8b5f68c03431bc95b72298 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/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;
 }