Changeset View
Changeset View
Standalone View
Standalone View
graphics/igt-gpu-tools/files/patch-lib_igt__perf.c
- This file was added.
--- lib/igt_perf.c.orig 2022-08-17 23:41:16 UTC | |||||
+++ lib/igt_perf.c | |||||
@@ -4,8 +4,10 @@ | |||||
#include <stdlib.h> | |||||
#include <string.h> | |||||
#include <sys/stat.h> | |||||
+#ifdef __linux__ | |||||
#include <sys/sysinfo.h> | |||||
#include <sys/sysmacros.h> | |||||
+#endif | |||||
#include <time.h> | |||||
#include <unistd.h> | |||||
@@ -13,6 +15,7 @@ static char *bus_address(int i915, char *path, int pat | |||||
static char *bus_address(int i915, char *path, int pathlen) | |||||
{ | |||||
+#ifdef __linux__ | |||||
struct stat st; | |||||
int len = -1; | |||||
int dir; | |||||
@@ -39,11 +42,13 @@ static char *bus_address(int i915, char *path, int pat | |||||
if (s) | |||||
memmove(path, s + 1, len - (s - path) + 1); | |||||
+#endif | |||||
return path; | |||||
} | |||||
const char *i915_perf_device(int i915, char *buf, int buflen) | |||||
{ | |||||
+#ifdef __linux__ | |||||
char *s; | |||||
#define prefix "i915_" | |||||
@@ -63,6 +68,7 @@ const char *i915_perf_device(int i915, char *buf, int | |||||
if (*s == ':') | |||||
*s = '_'; | |||||
+#endif | |||||
return buf; | |||||
} | |||||
@@ -99,6 +105,7 @@ _perf_open(uint64_t type, uint64_t config, int group, | |||||
static int | |||||
_perf_open(uint64_t type, uint64_t config, int group, uint64_t format) | |||||
{ | |||||
+#ifdef __linux__ | |||||
struct perf_event_attr attr = { }; | |||||
int nr_cpus = get_nprocs_conf(); | |||||
int cpu = 0, ret; | |||||
@@ -120,40 +127,67 @@ _perf_open(uint64_t type, uint64_t config, int group, | |||||
} while ((ret < 0 && errno == EINVAL) && (cpu < nr_cpus)); | |||||
return ret; | |||||
+#elif defined(__FreeBSD__) | |||||
+ return -ENOSYS; | |||||
+#endif | |||||
} | |||||
int perf_igfx_open(uint64_t config) | |||||
{ | |||||
+#ifdef __linux__ | |||||
return _perf_open(igt_perf_type_id("i915"), config, -1, | |||||
PERF_FORMAT_TOTAL_TIME_ENABLED); | |||||
+#elif defined(__FreeBSD__) | |||||
+ return -ENOSYS; | |||||
+#endif | |||||
} | |||||
int perf_igfx_open_group(uint64_t config, int group) | |||||
{ | |||||
+#ifdef __linux__ | |||||
return _perf_open(igt_perf_type_id("i915"), config, group, | |||||
PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP); | |||||
+#elif defined(__FreeBSD__) | |||||
+ return -ENOSYS; | |||||
+#endif | |||||
} | |||||
int perf_i915_open(int i915, uint64_t config) | |||||
{ | |||||
+#ifdef __linux__ | |||||
return _perf_open(i915_perf_type_id(i915), config, -1, | |||||
PERF_FORMAT_TOTAL_TIME_ENABLED); | |||||
+#elif defined(__FreeBSD__) | |||||
+ return -ENOSYS; | |||||
+#endif | |||||
} | |||||
int perf_i915_open_group(int i915, uint64_t config, int group) | |||||
{ | |||||
+#ifdef __linux__ | |||||
return _perf_open(i915_perf_type_id(i915), config, group, | |||||
PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP); | |||||
+#elif defined(__FreeBSD__) | |||||
+ return -ENOSYS; | |||||
+#endif | |||||
} | |||||
int igt_perf_open(uint64_t type, uint64_t config) | |||||
{ | |||||
+#ifdef __linux__ | |||||
return _perf_open(type, config, -1, | |||||
PERF_FORMAT_TOTAL_TIME_ENABLED); | |||||
+#elif defined(__FreeBSD__) | |||||
+ return -ENOSYS; | |||||
+#endif | |||||
} | |||||
int igt_perf_open_group(uint64_t type, uint64_t config, int group) | |||||
{ | |||||
+#ifdef __linux__ | |||||
return _perf_open(type, config, group, | |||||
PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP); | |||||
+#elif defined(__FreeBSD__) | |||||
+ return -ENOSYS; | |||||
+#endif | |||||
} |