Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Apr 2020 07:13:59 +0000 (UTC)
From:      Jan Beich <jbeich@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r532647 - in head/lang/intel-compute-runtime: . files
Message-ID:  <202004230713.03N7DxQT045178@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jbeich
Date: Thu Apr 23 07:13:58 2020
New Revision: 532647
URL: https://svnweb.freebsd.org/changeset/ports/532647

Log:
  lang/intel-compute-runtime: don't hardcode /dev/dri/card0
  
  Similar to https://github.com/intel/compute-runtime/commit/719b22ee117f

Modified:
  head/lang/intel-compute-runtime/Makefile   (contents, props changed)
  head/lang/intel-compute-runtime/files/patch-max_freq   (contents, props changed)

Modified: head/lang/intel-compute-runtime/Makefile
==============================================================================
--- head/lang/intel-compute-runtime/Makefile	Thu Apr 23 06:34:32 2020	(r532646)
+++ head/lang/intel-compute-runtime/Makefile	Thu Apr 23 07:13:58 2020	(r532647)
@@ -2,6 +2,7 @@
 
 PORTNAME=	compute-runtime
 DISTVERSION=	20.15.16524
+PORTREVISION=	1
 CATEGORIES=	lang
 PKGNAMEPREFIX=	intel-
 

Modified: head/lang/intel-compute-runtime/files/patch-max_freq
==============================================================================
--- head/lang/intel-compute-runtime/files/patch-max_freq	Thu Apr 23 06:34:32 2020	(r532646)
+++ head/lang/intel-compute-runtime/files/patch-max_freq	Thu Apr 23 07:13:58 2020	(r532647)
@@ -5,27 +5,43 @@
 
 --- shared/source/os_interface/linux/drm_neo.cpp.orig	2020-04-11 07:41:07 UTC
 +++ shared/source/os_interface/linux/drm_neo.cpp
-@@ -24,6 +24,11 @@
+@@ -24,6 +24,13 @@
  #include <fstream>
  #include <linux/limits.h>
  
 +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 +#include <sys/param.h>
 +#include <sys/sysctl.h>
++#include <sys/stat.h>
++#include <cstdlib>
 +#endif
 +
  namespace NEO {
  
  namespace IoctlHelper {
-@@ -104,6 +109,16 @@ int Drm::getEnabledPooledEu(int &enabled) {
+@@ -104,6 +111,30 @@ int Drm::getEnabledPooledEu(int &enabled) {
  
  int Drm::getMaxGpuFrequency(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))) {
++        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);
-+
-+    if (sysctlbyname("sys.class.drm.card0.gt_max_freq_mhz", &max_freq, &len, NULL, 0)) {
++    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;
 +    }
 +
@@ -34,7 +50,7 @@
      std::string clockSysFsPath = getSysFsPciPath();
  
      clockSysFsPath += "/gt_max_freq_mhz";
-@@ -115,6 +130,7 @@ int Drm::getMaxGpuFrequency(int &maxGpuFrequency) {
+@@ -115,6 +146,7 @@ int Drm::getMaxGpuFrequency(int &maxGpuFrequency) {
  
      ifs >> maxGpuFrequency;
      ifs.close();



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202004230713.03N7DxQT045178>