Index: head/lang/intel-compute-runtime/files/patch-max_freq =================================================================== --- head/lang/intel-compute-runtime/files/patch-max_freq (revision 533252) +++ head/lang/intel-compute-runtime/files/patch-max_freq (revision 533253) @@ -1,57 +1,53 @@ /sys/bus/pci/devices doesn't exist as kms-drm exports sysfs via sysctl $ clinfo | fgrep clock Max clock frequency 0MHz --- shared/source/os_interface/linux/drm_query.cpp.orig 2020-04-17 18:43:38 UTC +++ shared/source/os_interface/linux/drm_query.cpp -@@ -11,10 +11,41 @@ +@@ -11,10 +11,37 @@ #include +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#include +#include -+#include ++#include +#include +#endif + namespace NEO { int Drm::getMaxGpuFrequency(HardwareInfo &hwInfo, int &maxGpuFrequency) { maxGpuFrequency = 0; +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -+ struct stat sb; -+ if (fstat(getFileDescriptor(), &sb)) { -+ return 0; -+ } + char name[SPECNAMELEN + 1]; -+ if (!devname_r(sb.st_rdev, S_IFCHR, name, sizeof(name))) { ++ 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"; -@@ -26,6 +57,7 @@ int Drm::getMaxGpuFrequency(HardwareInfo &hwInfo, int +@@ -26,6 +53,7 @@ int Drm::getMaxGpuFrequency(HardwareInfo &hwInfo, int ifs >> maxGpuFrequency; ifs.close(); +#endif return 0; }