2019-12-24 01:26:32 +01:00
|
|
|
/sys/bus/pci/devices doesn't exist as kms-drm exports sysfs via sysctl
|
|
|
|
|
|
|
|
$ clinfo | fgrep clock
|
|
|
|
Max clock frequency 0MHz
|
|
|
|
|
2020-04-24 17:54:50 +02:00
|
|
|
--- shared/source/os_interface/linux/drm_query.cpp.orig 2020-04-17 18:43:38 UTC
|
|
|
|
+++ shared/source/os_interface/linux/drm_query.cpp
|
2020-04-28 17:10:22 +02:00
|
|
|
@@ -11,10 +11,37 @@
|
2020-04-24 17:54:50 +02:00
|
|
|
|
2019-12-24 01:26:32 +01:00
|
|
|
#include <fstream>
|
|
|
|
|
2020-07-24 00:34:26 +02:00
|
|
|
+#if defined(__FreeBSD__)
|
2019-12-24 01:26:32 +01:00
|
|
|
+#include <sys/param.h>
|
|
|
|
+#include <sys/sysctl.h>
|
2020-04-28 17:10:22 +02:00
|
|
|
+#include <cstdio>
|
2020-04-23 09:13:58 +02:00
|
|
|
+#include <cstdlib>
|
2019-12-24 01:26:32 +01:00
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
namespace NEO {
|
|
|
|
|
2020-04-24 17:54:50 +02:00
|
|
|
int Drm::getMaxGpuFrequency(HardwareInfo &hwInfo, int &maxGpuFrequency) {
|
2019-12-24 01:26:32 +01:00
|
|
|
maxGpuFrequency = 0;
|
2020-07-24 00:34:26 +02:00
|
|
|
+#if defined(__FreeBSD__)
|
2020-04-23 09:13:58 +02:00
|
|
|
+ char name[SPECNAMELEN + 1];
|
2020-04-28 17:10:22 +02:00
|
|
|
+ if (!fdevname_r(getFileDescriptor(), name, sizeof(name))) {
|
2020-04-23 09:13:58 +02:00
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ int id;
|
|
|
|
+ if (!sscanf(name, "drm/%d", &id) && !sscanf(name, "dri/renderD%d", &id)) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ char oid[MAXPATHLEN + 1];
|
2019-12-24 01:26:32 +01:00
|
|
|
+ char max_freq[PAGE_SIZE];
|
|
|
|
+ size_t len = sizeof(max_freq);
|
2020-04-23 09:13:58 +02:00
|
|
|
+ snprintf(oid, sizeof(oid), "sys.class.drm.card%d.gt_max_freq_mhz", id - 128);
|
|
|
|
+ if (sysctlbyname(oid, &max_freq, &len, NULL, 0)) {
|
2019-12-24 01:26:32 +01:00
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ maxGpuFrequency = std::stoi(max_freq);
|
|
|
|
+#else
|
2020-04-17 16:49:31 +02:00
|
|
|
std::string clockSysFsPath = getSysFsPciPath();
|
|
|
|
|
|
|
|
clockSysFsPath += "/gt_max_freq_mhz";
|
2020-04-28 17:10:22 +02:00
|
|
|
@@ -26,6 +53,7 @@ int Drm::getMaxGpuFrequency(HardwareInfo &hwInfo, int
|
2019-12-24 01:26:32 +01:00
|
|
|
|
|
|
|
ifs >> maxGpuFrequency;
|
|
|
|
ifs.close();
|
|
|
|
+#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-11-14 20:42:17 +01:00
|
|
|
--- shared/source/os_interface/linux/drm_query_dg1.cpp.orig 2020-11-07 13:04:57 UTC
|
|
|
|
+++ shared/source/os_interface/linux/drm_query_dg1.cpp
|
|
|
|
@@ -13,11 +13,38 @@
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
+#if defined(__FreeBSD__)
|
|
|
|
+#include <sys/param.h>
|
|
|
|
+#include <sys/sysctl.h>
|
|
|
|
+#include <cstdio>
|
|
|
|
+#include <cstdlib>
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
namespace NEO {
|
|
|
|
class OsContext;
|
|
|
|
|
|
|
|
int Drm::getMaxGpuFrequency(HardwareInfo &hwInfo, int &maxGpuFrequency) {
|
|
|
|
maxGpuFrequency = 0;
|
|
|
|
+#if defined(__FreeBSD__)
|
|
|
|
+ char name[SPECNAMELEN + 1];
|
|
|
|
+ if (!fdevname_r(getFileDescriptor(), name, sizeof(name))) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ int id;
|
|
|
|
+ if (!sscanf(name, "drm/%d", &id) && !sscanf(name, "dri/renderD%d", &id)) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ char oid[MAXPATHLEN + 1];
|
|
|
|
+ char max_freq[PAGE_SIZE];
|
|
|
|
+ size_t len = sizeof(max_freq);
|
|
|
|
+ snprintf(oid, sizeof(oid), "sys.class.drm.card%d.gt_max_freq_mhz", id - 128);
|
|
|
|
+ if (sysctlbyname(oid, &max_freq, &len, NULL, 0)) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ maxGpuFrequency = std::stoi(max_freq);
|
|
|
|
+#else
|
|
|
|
std::string clockSysFsPath = getSysFsPciPath();
|
|
|
|
|
|
|
|
clockSysFsPath += "/gt_max_freq_mhz";
|
|
|
|
@@ -29,6 +56,7 @@ int Drm::getMaxGpuFrequency(HardwareInfo &hwInfo, int
|
|
|
|
|
|
|
|
ifs >> maxGpuFrequency;
|
|
|
|
ifs.close();
|
|
|
|
+#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|