Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Sep 2022 15:07:59 GMT
From:      Joseph Mingrone <jrm@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 5d303ab48075 - main - graphics/igt-gpu-tools: Test suite for drm drivers
Message-ID:  <202209091507.289F7xNA083436@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by jrm:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5d303ab480752af223894480f7494e23785e9cd7

commit 5d303ab480752af223894480f7494e23785e9cd7
Author:     Jake Freeland <jfree@FreeBSD.org>
AuthorDate: 2022-09-08 18:44:40 +0000
Commit:     Joseph Mingrone <jrm@FreeBSD.org>
CommitDate: 2022-09-09 15:06:45 +0000

    graphics/igt-gpu-tools: Test suite for drm drivers
    
    The igt testing suite is separated into tests and tools that target kms,
    memory management, and command submission.  These tests are especially
    helpful for low-level reporting, transparent tracking of kernel changes,
    and efficient debugging of modern drm drivers.
    
    Reviewed by:    diizzy, lwhsu, jrm
    Differential Revision:  https://reviews.freebsd.org/D36213
---
 graphics/Makefile                                  |   1 +
 graphics/igt-gpu-tools/Makefile                    |  70 +++
 graphics/igt-gpu-tools/distinfo                    |   3 +
 .../files/patch-benchmarks_gem__exec__tracer.c     |  13 +
 .../files/patch-benchmarks_gem__syslatency.c       |  24 +
 .../files/patch-include_linux-uapi_sync__file.h    |  19 +
 .../files/patch-lib_i915_gem__engine__topology.c   |  13 +
 .../igt-gpu-tools/files/patch-lib_i915_gem__mman.c |  14 +
 .../files/patch-lib_i915_intel__memory__region.c   |  14 +
 graphics/igt-gpu-tools/files/patch-lib_i915_perf.c |  12 +
 .../igt-gpu-tools/files/patch-lib_igt__audio.c     |  13 +
 graphics/igt-gpu-tools/files/patch-lib_igt__aux.c  |  75 ++++
 graphics/igt-gpu-tools/files/patch-lib_igt__aux.h  |  23 +
 graphics/igt-gpu-tools/files/patch-lib_igt__core.c |  54 +++
 graphics/igt-gpu-tools/files/patch-lib_igt__core.h |  23 +
 .../igt-gpu-tools/files/patch-lib_igt__debugfs.c   |  23 +
 .../igt-gpu-tools/files/patch-lib_igt__device.c    |  12 +
 .../files/patch-lib_igt__device__scan.c            |  14 +
 .../igt-gpu-tools/files/patch-lib_igt__dummyload.c |  29 ++
 graphics/igt-gpu-tools/files/patch-lib_igt__eld.c  |  13 +
 .../igt-gpu-tools/files/patch-lib_igt__frame.c     |  13 +
 graphics/igt-gpu-tools/files/patch-lib_igt__kmod.c | 131 ++++++
 graphics/igt-gpu-tools/files/patch-lib_igt__kmod.h |  12 +
 graphics/igt-gpu-tools/files/patch-lib_igt__kms.c  |  13 +
 graphics/igt-gpu-tools/files/patch-lib_igt__os.c   |  42 ++
 graphics/igt-gpu-tools/files/patch-lib_igt__perf.c |  78 ++++
 graphics/igt-gpu-tools/files/patch-lib_igt__perf.h |  24 +
 graphics/igt-gpu-tools/files/patch-lib_igt__pm.c   |  12 +
 .../igt-gpu-tools/files/patch-lib_igt__syncobj.c   |  13 +
 .../igt-gpu-tools/files/patch-lib_igt__sysfs.c     |  12 +
 graphics/igt-gpu-tools/files/patch-lib_igt__vgem.c |  14 +
 .../files/patch-lib_intel__allocator.c             |  13 +
 .../files/patch-lib_intel__batchbuffer.c           |  14 +
 graphics/igt-gpu-tools/files/patch-lib_sw__sync.c  |  13 +
 .../files/patch-lib_tests_igt__exit__handler.c     |  12 +
 .../files/patch-lib_tests_igt__fork.c              |  14 +
 .../files/patch-lib_tests_igt__tests__common.h     |  20 +
 graphics/igt-gpu-tools/files/patch-meson.build     |  31 ++
 .../igt-gpu-tools/files/patch-runner_executor.c    |  39 ++
 .../igt-gpu-tools/files/patch-runner_job__list.c   |  72 +++
 .../files/patch-runner_runner__tests.c             | 183 ++++++++
 .../igt-gpu-tools/files/patch-runner_settings.c    |  51 +++
 .../igt-gpu-tools/files/patch-tests_core__auth.c   |  13 +
 .../files/patch-tests_drm__import__export.c        |  13 +
 .../igt-gpu-tools/files/patch-tests_dumb__buffer.c |  14 +
 .../files/patch-tests_i915_gem__close__race.c      |  23 +
 .../files/patch-tests_i915_gem__concurrent__all.c  |  14 +
 .../files/patch-tests_i915_gem__create.c           |  13 +
 .../files/patch-tests_i915_gem__ctx__exec.c        |  13 +
 .../files/patch-tests_i915_gem__ctx__persistence.c |  13 +
 .../files/patch-tests_i915_gem__ctx__shared.c      |  13 +
 .../files/patch-tests_i915_gem__exec__fence.c      |  13 +
 .../files/patch-tests_i915_gem__exec__latency.c    |  13 +
 .../files/patch-tests_i915_gem__exec__schedule.c   |  67 +++
 .../files/patch-tests_i915_gem__lmem__swapping.c   |  13 +
 .../files/patch-tests_i915_gem__madvise.c          |  13 +
 .../files/patch-tests_i915_gem__mmap__gtt.c        |  31 ++
 .../files/patch-tests_i915_gem__mmap__offset.c     |  31 ++
 .../files/patch-tests_i915_gem__pread.c            |  40 ++
 .../files/patch-tests_i915_gem__pwrite.c           |  40 ++
 .../files/patch-tests_i915_gem__shrink.c           |  13 +
 .../files/patch-tests_i915_gem__userptr__blits.c   |  52 +++
 .../files/patch-tests_i915_gem__wait.c             |  13 +
 .../files/patch-tests_i915_i915__hangman.c         |  13 +
 .../files/patch-tests_i915_i915__module__load.c    |  12 +
 .../files/patch-tests_i915_i915__pm__backlight.c   |  13 +
 .../files/patch-tests_i915_i915__pm__rpm.c         |  31 ++
 .../files/patch-tests_i915_kms__psr2__su.c         |  18 +
 .../patch-tests_i915_kms__psr__stress__test.c      |  32 ++
 .../patch-tests_i915_sysfs__heartbeat__interval.c  |  13 +
 .../files/patch-tests_kms__content__protection.c   |  12 +
 .../files/patch-tests_kms__cursor__legacy.c        |  13 +
 .../igt-gpu-tools/files/patch-tests_kms__flip.c    |  13 +
 .../files/patch-tests_kms__sysfs__edid__timing.c   |  13 +
 .../igt-gpu-tools/files/patch-tests_meson.build    | 174 +++++++
 .../igt-gpu-tools/files/patch-tests_sw__sync.c     |  12 +
 .../files/patch-tests_syncobj__timeline.c          |  13 +
 .../files/patch-tests_syncobj__wait.c              |  13 +
 .../igt-gpu-tools/files/patch-tests_tools__test.c  |  15 +
 .../files/patch-tests_vc4__purgeable__bo.c         |  13 +
 .../files/patch-tests_vc4__wait__bo.c              |  13 +
 .../files/patch-tests_vc4__wait__seqno.c           |  13 +
 .../files/patch-tools_intel__gvtg__test.c          |  12 +
 .../igt-gpu-tools/files/patch-tools_meson.build    |  24 +
 graphics/igt-gpu-tools/pkg-descr                   |   7 +
 graphics/igt-gpu-tools/pkg-plist                   | 498 +++++++++++++++++++++
 86 files changed, 2746 insertions(+)

diff --git a/graphics/Makefile b/graphics/Makefile
index 08b6ea89c477..26c2447b9337 100644
--- a/graphics/Makefile
+++ b/graphics/Makefile
@@ -352,6 +352,7 @@
     SUBDIR += icoutils
     SUBDIR += ida
     SUBDIR += iec16022
+    SUBDIR += igt-gpu-tools
     SUBDIR += iiview
     SUBDIR += ikona
     SUBDIR += imageindex
diff --git a/graphics/igt-gpu-tools/Makefile b/graphics/igt-gpu-tools/Makefile
new file mode 100644
index 000000000000..e7a9a1ce4eab
--- /dev/null
+++ b/graphics/igt-gpu-tools/Makefile
@@ -0,0 +1,70 @@
+PORTNAME=	igt-gpu-tools
+DISTVERSION=	1.26.1266
+CATEGORIES=	graphics
+
+MAINTAINER=	jfree@FreeBSD.org
+COMMENT=	IGT gpu tools and tests
+WWW=		https://drm.pages.freedesktop.org/igt-gpu-tools/
+
+LICENSE=	MIT
+LICENSE_FILE=	${WRKSRC}/COPYING
+
+IGNORE_FreeBSD_12=	unsupported on FreeBSD versions < 13.1
+
+BUILD_DEPENDS=	rst2man:textproc/py-docutils@${PY_FLAVOR}
+LIB_DEPENDS=	libdrm.so:graphics/libdrm \
+		libdw.so:devel/elfutils \
+		libpciaccess.so:devel/libpciaccess \
+		libudev.so:devel/libudev-devd
+
+USES=		bison gnome meson pkgconfig python shebangfix xorg
+
+USE_GITLAB=	yes
+GL_SITE=	https://gitlab.freedesktop.org
+GL_ACCOUNT=	drm
+GL_COMMIT=	9338ab3ec085292817ab1e74d1f2fb90b6a98332
+
+USE_GNOME=	cairo glib20
+
+USE_LDCONFIG=	yes
+
+USE_XORG=	pixman
+
+SHEBANG_FILES=	scripts/code_cov_gather_on_test scripts/code_cov_parse_info
+
+OPTIONS_DEFINE=		CHAMELIUM DOCS RUNNER TEST
+OPTIONS_DEFAULT=	DOCS RUNNER TEST
+
+OPTIONS_SUB=	yes
+
+CHAMELIUM_DESC=	Build chamelium display tests
+RUNNER_DESC=	Build test runner
+
+CHAMELIUM_IMPLIES=		TEST
+CHAMELIUM_LIB_DEPENDS=		libasound.so:audio/alsa-lib \
+				libcurl.so:ftp/curl \
+				libgsl.so:math/gsl \
+				libxmlrpc.so:net/xmlrpc-c
+CHAMELIUM_MESON_ENABLED=	chamelium
+
+DOCS_IMPLIES=		TEST
+DOCS_BUILD_DEPENDS=	gtkdoc-mkhtml:textproc/gtk-doc
+DOCS_MESON_ENABLED=	docs
+
+RUNNER_IMPLIES=		TEST
+RUNNER_LIB_DEPENDS=	libjson-c.so:devel/json-c \
+			liboping.so:net/liboping
+RUNNER_MESON_ENABLED=	runner
+
+TEST_LIB_DEPENDS=	libunwind.so:devel/libunwind
+TEST_MESON_ENABLED=	tests
+
+.include <bsd.port.options.mk>
+
+.if ${ARCH} == "amd64"
+PLIST_SUB+=	AMD64=""
+.else
+PLIST_SUB+=	AMD64="@comment "
+.endif
+
+.include <bsd.port.mk>
diff --git a/graphics/igt-gpu-tools/distinfo b/graphics/igt-gpu-tools/distinfo
new file mode 100644
index 000000000000..d1c1376ca171
--- /dev/null
+++ b/graphics/igt-gpu-tools/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1661919740
+SHA256 (drm-igt-gpu-tools-9338ab3ec085292817ab1e74d1f2fb90b6a98332_GL0.tar.gz) = c1b1ce7c3370e4e7030c76d43a312ba655d567c8f427b48f451525f81ef0a833
+SIZE (drm-igt-gpu-tools-9338ab3ec085292817ab1e74d1f2fb90b6a98332_GL0.tar.gz) = 2936270
diff --git a/graphics/igt-gpu-tools/files/patch-benchmarks_gem__exec__tracer.c b/graphics/igt-gpu-tools/files/patch-benchmarks_gem__exec__tracer.c
new file mode 100644
index 000000000000..59708e57f20e
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-benchmarks_gem__exec__tracer.c
@@ -0,0 +1,13 @@
+--- benchmarks/gem_exec_tracer.c.orig	2022-08-31 20:00:00 UTC
++++ benchmarks/gem_exec_tracer.c
+@@ -41,6 +41,10 @@
+ #include "intel_aub.h"
+ #include "intel_chipset.h"
+ 
++#ifdef __FreeBSD__
++#define	_IOC_TYPE(nr)	(((nr) >> 8) & 255)
++#endif
++
+ static int (*libc_close)(int fd);
+ static int (*libc_ioctl)(int fd, unsigned long request, void *argp);
+ 
diff --git a/graphics/igt-gpu-tools/files/patch-benchmarks_gem__syslatency.c b/graphics/igt-gpu-tools/files/patch-benchmarks_gem__syslatency.c
new file mode 100644
index 000000000000..717c89777bae
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-benchmarks_gem__syslatency.c
@@ -0,0 +1,24 @@
+--- benchmarks/gem_syslatency.c.orig	2022-08-31 20:00:00 UTC
++++ benchmarks/gem_syslatency.c
+@@ -42,12 +42,21 @@
+ #include <limits.h>
+ #include "drm.h"
+ 
++#ifdef __linux__
+ #include <linux/unistd.h>
++#elif defined(__FreeBSD__)
++#include <sys/mman.h>
++#define	MAP_POPULATE	MAP_PREFAULT_READ
++#define	gettid()	getpid()
++#define	MADV_HUGEPAGE	MADV_SEQUENTIAL
++#endif
+ 
+ #include "i915/gem_create.h"
+ #include "i915/gem_ring.h"
+ 
++#ifdef __linux__
+ #define sigev_notify_thread_id _sigev_un._tid
++#endif
+ 
+ static volatile int done;
+ 
diff --git a/graphics/igt-gpu-tools/files/patch-include_linux-uapi_sync__file.h b/graphics/igt-gpu-tools/files/patch-include_linux-uapi_sync__file.h
new file mode 100644
index 000000000000..9fa37118dde4
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-include_linux-uapi_sync__file.h
@@ -0,0 +1,19 @@
+--- include/linux-uapi/sync_file.h.orig	2022-08-31 20:00:01 UTC
++++ include/linux-uapi/sync_file.h
+@@ -12,8 +12,16 @@
+ #ifndef _LINUX_SYNC_H
+ #define _LINUX_SYNC_H
+ 
++#ifdef __linux__
+ #include <linux/ioctl.h>
+ #include <linux/types.h>
++#elif defined(__FreeBSD__)
++#include <sys/ioctl.h>
++#include <sys/types.h>
++#define	__s32	int32_t
++#define	__u32	uint32_t
++#define	__u64	uint64_t
++#endif
+ 
+ /**
+  * struct sync_merge_data - data passed to merge ioctl
diff --git a/graphics/igt-gpu-tools/files/patch-lib_i915_gem__engine__topology.c b/graphics/igt-gpu-tools/files/patch-lib_i915_gem__engine__topology.c
new file mode 100644
index 000000000000..8ee04959a904
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_i915_gem__engine__topology.c
@@ -0,0 +1,13 @@
+--- lib/i915/gem_engine_topology.c.orig	2022-08-31 20:00:01 UTC
++++ lib/i915/gem_engine_topology.c
+@@ -88,6 +88,10 @@
+  */
+ #define SIZEOF_QUERY		offsetof(struct drm_i915_query_engine_info, \
+ 					 engines[GEM_MAX_ENGINES])
++#ifdef __FreeBSD__
++#define	SYS_getdents64	SYS_freebsd11_getdents
++#define	ino64_t		ino_t
++#endif
+ 
+ static int __gem_query(int fd, struct drm_i915_query *q)
+ {
diff --git a/graphics/igt-gpu-tools/files/patch-lib_i915_gem__mman.c b/graphics/igt-gpu-tools/files/patch-lib_i915_gem__mman.c
new file mode 100644
index 000000000000..d16771ef15b1
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_i915_gem__mman.c
@@ -0,0 +1,14 @@
+--- lib/i915/gem_mman.c.orig	2022-08-31 20:00:01 UTC
++++ lib/i915/gem_mman.c
+@@ -44,6 +44,11 @@
+ #define VG(x) do {} while (0)
+ #endif
+ 
++#ifdef __FreeBSD__
++#define	mmap64(addr, len, prot, flags, fd, offset) \
++	mmap(addr, len, prot, flags, fd, offset)
++#endif
++
+ static int gem_mmap_gtt_version(int fd)
+ {
+ 	struct drm_i915_getparam gp;
diff --git a/graphics/igt-gpu-tools/files/patch-lib_i915_intel__memory__region.c b/graphics/igt-gpu-tools/files/patch-lib_i915_intel__memory__region.c
new file mode 100644
index 000000000000..c4f07d793b96
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_i915_intel__memory__region.c
@@ -0,0 +1,14 @@
+--- lib/i915/intel_memory_region.c.orig	2022-08-31 20:00:01 UTC
++++ lib/i915/intel_memory_region.c
+@@ -21,7 +21,11 @@
+  * IN THE SOFTWARE.
+  */
+ 
++#ifdef __linux__
+ #include <linux/limits.h>
++#elif defined(__FreeBSD__)
++#include <sys/limits.h>
++#endif
+ #include <signal.h>
+ #include <sys/ioctl.h>
+ #include <sys/time.h>
diff --git a/graphics/igt-gpu-tools/files/patch-lib_i915_perf.c b/graphics/igt-gpu-tools/files/patch-lib_i915_perf.c
new file mode 100644
index 000000000000..91b6cf3bde11
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_i915_perf.c
@@ -0,0 +1,12 @@
+--- lib/i915/perf.c.orig	2022-08-31 20:00:01 UTC
++++ lib/i915/perf.c
+@@ -29,7 +29,9 @@
+ #include <fcntl.h>
+ #include <sys/ioctl.h>
+ #include <sys/stat.h>
++#ifdef __linux__
+ #include <sys/sysmacros.h>
++#endif
+ #include <sys/types.h>
+ #include <unistd.h>
+ 
diff --git a/graphics/igt-gpu-tools/files/patch-lib_igt__audio.c b/graphics/igt-gpu-tools/files/patch-lib_igt__audio.c
new file mode 100644
index 000000000000..bb6d184cae02
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_igt__audio.c
@@ -0,0 +1,13 @@
+--- lib/igt_audio.c.orig	2022-08-31 20:00:01 UTC
++++ lib/igt_audio.c
+@@ -26,6 +26,10 @@
+ 
+ #include "config.h"
+ 
++#ifdef __FreeBSD__
++#include <limits.h>
++#endif
++
+ #include <errno.h>
+ #include <fcntl.h>
+ #include <gsl/gsl_fft_real.h>
diff --git a/graphics/igt-gpu-tools/files/patch-lib_igt__aux.c b/graphics/igt-gpu-tools/files/patch-lib_igt__aux.c
new file mode 100644
index 000000000000..77a1539a3e4f
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_igt__aux.c
@@ -0,0 +1,75 @@
+--- lib/igt_aux.c.orig	2022-08-31 20:00:01 UTC
++++ lib/igt_aux.c
+@@ -52,7 +52,9 @@
+ #include <assert.h>
+ #include <grp.h>
+ 
++#ifdef __linux__
+ #include <proc/readproc.h>
++#endif
+ #include <libudev.h>
+ 
+ #include "drmtest.h"
+@@ -75,6 +77,12 @@
+ #include <libgen.h>   /* for dirname() */
+ #endif
+ 
++#ifdef __FreeBSD__
++typedef struct { char state; } proc_t;
++#define	gettid()	getpid()
++#define	setpgrp()	setpgid(0, 0)
++#endif
++
+ /**
+  * SECTION:igt_aux
+  * @short_description: Auxiliary libraries and support functions
+@@ -1206,6 +1214,7 @@ void igt_unlock_mem(void)
+ 	locked_mem = NULL;
+ }
+ 
++#ifdef __linux__
+ /**
+  * igt_is_process_running:
+  * @comm: Name of process in the form found in /proc/pid/comm (limited to 15
+@@ -1780,6 +1789,41 @@ igt_lsof_kill_audio_processes(void)
+ 
+ 	return fail;
+ }
++#elif defined(__FreeBSD__)
++int
++igt_is_process_running(const char *comm)
++{
++	return -ENOSYS;
++}
++
++int
++igt_terminate_process(int sig, const char *comm)
++{
++	return -ENOSYS;
++}
++
++void
++igt_lsof(const char *dpath)
++{
++}
++
++int
++igt_lsof_kill_audio_processes(void)
++{
++	return -ENOSYS;
++}
++
++int
++pipewire_pulse_start_reserve(void)
++{
++	return -ENOSYS;
++}
++
++void
++pipewire_pulse_stop_reserve(void)
++{
++}
++#endif /* __linux__ */
+ 
+ static struct igt_siglatency {
+ 	timer_t timer;
diff --git a/graphics/igt-gpu-tools/files/patch-lib_igt__aux.h b/graphics/igt-gpu-tools/files/patch-lib_igt__aux.h
new file mode 100644
index 000000000000..fc083392b2e7
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_igt__aux.h
@@ -0,0 +1,23 @@
+--- lib/igt_aux.h.orig	2022-08-31 20:00:01 UTC
++++ lib/igt_aux.h
+@@ -34,9 +34,7 @@
+ #include <sys/time.h>
+ #include <sys/types.h>
+ #include <unistd.h>
+-#ifdef __linux__
+-# include <sys/syscall.h>
+-#endif
++#include <sys/syscall.h>
+ 
+ #include <i915/gem_submission.h>
+ 
+@@ -48,8 +46,8 @@
+ # ifndef HAVE_GETTID
+ #  define gettid() (pid_t)(syscall(__NR_gettid))
+ # endif
+-#endif
+ #define sigev_notify_thread_id _sigev_un._tid
++#endif
+ 
+ /* auxialiary igt helpers from igt_aux.c */
+ /* generally useful helpers */
diff --git a/graphics/igt-gpu-tools/files/patch-lib_igt__core.c b/graphics/igt-gpu-tools/files/patch-lib_igt__core.c
new file mode 100644
index 000000000000..012fae47e743
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_igt__core.c
@@ -0,0 +1,54 @@
+--- lib/igt_core.c.orig	2022-08-31 20:00:01 UTC
++++ lib/igt_core.c
+@@ -43,7 +43,7 @@
+ #include <unistd.h>
+ #include <sys/wait.h>
+ #include <sys/types.h>
+-#ifdef __linux__
++#if defined(__linux__) || defined(__FreeBSD__)
+ #include <sys/syscall.h>
+ #endif
+ #include <pthread.h>
+@@ -85,6 +85,12 @@
+ #include <libgen.h>   /* for basename() on Solaris */
+ #endif
+ 
++#ifdef __FreeBSD__
++#define	gettid()				getpid()
++#define	pthread_sigqueue(pid, signo, value)	sigqueue(pid, signo, value)
++#define	sighandler_t				sig_t
++#endif
++
+ /**
+  * SECTION:igt_core
+  * @short_description: Core i-g-t testing support
+@@ -786,6 +792,7 @@ static void oom_adjust_for_doom(void)
+ 
+ static void oom_adjust_for_doom(void)
+ {
++#ifdef __linux__
+ 	int fd;
+ 	const char always_kill[] = "1000";
+ 
+@@ -793,7 +800,7 @@ static void oom_adjust_for_doom(void)
+ 	igt_assert(fd != -1);
+ 	igt_assert(write(fd, always_kill, sizeof(always_kill)) == sizeof(always_kill));
+ 	close(fd);
+-
++#endif
+ }
+ 
+ /**
+@@ -2223,7 +2230,12 @@ bool __igt_fork_helper(struct igt_helper_process *proc
+ 		igt_assert(0);
+ 	case 0:
+ 		reset_helper_process_list();
++#ifdef __linux__
+ 		oom_adjust_for_doom();
++#elif defined(__FreeBSD__)
++		/* not a great substitution for oom_adjust_for_doom() */
++		raise(SIGTERM);
++#endif
+ 
+ 		return true;
+ 	default:
diff --git a/graphics/igt-gpu-tools/files/patch-lib_igt__core.h b/graphics/igt-gpu-tools/files/patch-lib_igt__core.h
new file mode 100644
index 000000000000..42c8b79da821
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_igt__core.h
@@ -0,0 +1,23 @@
+--- lib/igt_core.h.orig	2022-08-31 20:00:01 UTC
++++ lib/igt_core.h
+@@ -31,7 +31,9 @@
+ #define IGT_CORE_H
+ 
+ #include <assert.h>
++#ifdef __linux__
+ #include <byteswap.h>
++#endif
+ #include <setjmp.h>
+ #include <stdbool.h>
+ #include <stdint.h>
+@@ -47,6 +49,10 @@
+ #define IGT_LOG_DOMAIN (NULL)
+ #endif
+ 
++#ifdef __FreeBSD__
++#include <signal.h>
++#define	jmp_buf	sigjmp_buf
++#endif
+ 
+ #ifndef STATIC_ANALYSIS_BUILD
+ #if defined(__clang_analyzer__) || defined(__COVERITY__) || defined(__KLOCWORK__)
diff --git a/graphics/igt-gpu-tools/files/patch-lib_igt__debugfs.c b/graphics/igt-gpu-tools/files/patch-lib_igt__debugfs.c
new file mode 100644
index 000000000000..101d77f388e3
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_igt__debugfs.c
@@ -0,0 +1,23 @@
+--- lib/igt_debugfs.c.orig	2022-08-31 20:00:01 UTC
++++ lib/igt_debugfs.c
+@@ -25,7 +25,9 @@
+ #include <inttypes.h>
+ #include <sys/stat.h>
+ #include <sys/mount.h>
++#ifdef __linux__
+ #include <sys/sysmacros.h>
++#endif
+ #include <dirent.h>
+ #include <errno.h>
+ #include <stdio.h>
+@@ -42,6 +44,10 @@
+ #include "igt_kms.h"
+ #include "igt_debugfs.h"
+ #include "igt_sysfs.h"
++
++#ifdef __FreeBSD__
++#define	mount(src, dest, fstype, flags, data)	mount(fstype, dest, flags, data)
++#endif
+ 
+ /**
+  * SECTION:igt_debugfs
diff --git a/graphics/igt-gpu-tools/files/patch-lib_igt__device.c b/graphics/igt-gpu-tools/files/patch-lib_igt__device.c
new file mode 100644
index 000000000000..edaf51f33e21
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_igt__device.c
@@ -0,0 +1,12 @@
+--- lib/igt_device.c.orig	2022-08-31 20:00:01 UTC
++++ lib/igt_device.c
+@@ -25,7 +25,9 @@
+ #include <fcntl.h>
+ 
+ #include <sys/stat.h>
++#ifdef __linux__
+ #include <sys/sysmacros.h>
++#endif
+ #include "igt.h"
+ #include "igt_device.h"
+ #include "igt_sysfs.h"
diff --git a/graphics/igt-gpu-tools/files/patch-lib_igt__device__scan.c b/graphics/igt-gpu-tools/files/patch-lib_igt__device__scan.c
new file mode 100644
index 000000000000..ece786e14737
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_igt__device__scan.c
@@ -0,0 +1,14 @@
+--- lib/igt_device_scan.c.orig	2022-08-31 20:00:01 UTC
++++ lib/igt_device_scan.c
+@@ -32,7 +32,11 @@
+ #include <fcntl.h>
+ #include <glib.h>
+ #include <libudev.h>
++#ifdef __linux__
+ #include <linux/limits.h>
++#elif defined(__FreeBSD__)
++#include <limits.h>
++#endif
+ #include <sys/stat.h>
+ #include <sys/time.h>
+ #include <sys/types.h>
diff --git a/graphics/igt-gpu-tools/files/patch-lib_igt__dummyload.c b/graphics/igt-gpu-tools/files/patch-lib_igt__dummyload.c
new file mode 100644
index 000000000000..d97cc17f961d
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_igt__dummyload.c
@@ -0,0 +1,29 @@
+--- lib/igt_dummyload.c.orig	2022-08-31 20:00:01 UTC
++++ lib/igt_dummyload.c
+@@ -26,7 +26,9 @@
+ #include <signal.h>
+ #include <pthread.h>
+ #include <sys/poll.h>
++#ifdef __linux__
+ #include <sys/timerfd.h>
++#endif
+ 
+ #include <i915_drm.h>
+ 
+@@ -523,6 +525,8 @@ void igt_spin_set_timeout(igt_spin_t *spin, int64_t ns
+  */
+ void igt_spin_set_timeout(igt_spin_t *spin, int64_t ns)
+ {
++/* TODO: FreeBSD - POSIX TIMER */
++#ifdef __linux__
+ 	struct sched_param param = { .sched_priority = 99 };
+ 	struct itimerspec its;
+ 	pthread_attr_t attr;
+@@ -554,6 +558,7 @@ void igt_spin_set_timeout(igt_spin_t *spin, int64_t ns
+ 	its.it_value.tv_sec = ns / NSEC_PER_SEC;
+ 	its.it_value.tv_nsec = ns % NSEC_PER_SEC;
+ 	igt_assert(timerfd_settime(timerfd, 0, &its, NULL) == 0);
++#endif
+ }
+ 
+ static void sync_write(igt_spin_t *spin, uint32_t value)
diff --git a/graphics/igt-gpu-tools/files/patch-lib_igt__eld.c b/graphics/igt-gpu-tools/files/patch-lib_igt__eld.c
new file mode 100644
index 000000000000..ed32b1dafcaa
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_igt__eld.c
@@ -0,0 +1,13 @@
+--- lib/igt_eld.c.orig	2022-08-31 20:00:01 UTC
++++ lib/igt_eld.c
+@@ -23,6 +23,10 @@
+  * Authors: Simon Ser <simon.ser@intel.com>
+  */
+ 
++#ifdef __FreeBSD__
++#include <limits.h>
++#endif
++
+ #include "config.h"
+ 
+ #include <dirent.h>
diff --git a/graphics/igt-gpu-tools/files/patch-lib_igt__frame.c b/graphics/igt-gpu-tools/files/patch-lib_igt__frame.c
new file mode 100644
index 000000000000..475a54bf3c5f
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_igt__frame.c
@@ -0,0 +1,13 @@
+--- lib/igt_frame.c.orig	2022-08-31 20:00:01 UTC
++++ lib/igt_frame.c
+@@ -24,6 +24,10 @@
+  *  Paul Kocialkowski <paul.kocialkowski@linux.intel.com>
+  */
+ 
++#ifdef __FreeBSD__
++#include <limits.h>
++#endif
++
+ #include "config.h"
+ 
+ #include <fcntl.h>
diff --git a/graphics/igt-gpu-tools/files/patch-lib_igt__kmod.c b/graphics/igt-gpu-tools/files/patch-lib_igt__kmod.c
new file mode 100644
index 000000000000..d30a18aecc7d
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_igt__kmod.c
@@ -0,0 +1,131 @@
+--- lib/igt_kmod.c.orig	2022-08-31 20:00:01 UTC
++++ lib/igt_kmod.c
+@@ -32,6 +32,7 @@
+ #include "igt_sysfs.h"
+ #include "igt_taints.h"
+ 
++#ifdef __linux__
+ /**
+  * SECTION:igt_kmod
+  * @short_description: Wrappers around libkmod for module loading/unloading
+@@ -853,3 +854,120 @@ void igt_kselftests(const char *module_name,
+ 
+ 	igt_kselftest_fini(&tst);
+ }
++#elif defined(__FreeBSD__)
++struct kmod_module {
++	size_t size;
++};
++
++bool
++igt_kmod_is_loaded(const char *mod_name)
++{
++	return false;
++}
++
++void
++igt_kmod_list_loaded(void)
++{
++}
++
++bool
++igt_kmod_has_param(const char *mod_name, const char *param)
++{
++	return false;
++}
++
++int
++igt_kmod_load(const char *mod_name, const char *opts)
++{
++	return -ENOSYS;
++}
++
++int
++igt_kmod_unload(const char *mod_name, unsigned int flags)
++{
++	return -ENOSYS;
++}
++
++int
++igt_audio_driver_unload(char **whom)
++{
++	return -ENOSYS;
++}
++
++int
++igt_i915_driver_load(const char *opts)
++{
++	return -ENOSYS;
++}
++
++int
++igt_i915_driver_unload(void)
++{
++	return -ENOSYS;
++}
++
++int
++__igt_i915_driver_unload(char **whom)
++{
++	return -ENOSYS;
++}
++
++int
++igt_amdgpu_driver_load(const char *opts)
++{
++	return -ENOSYS;
++}
++
++int
++igt_amdgpu_driver_unload(void)
++{
++	return -ENOSYS;
++}
++
++void
++igt_kselftests(const char *module_name,
++    const char *module_options,
++    const char *result_option,
++    const char *filter)
++{
++}
++
++int
++igt_kselftest_init(struct igt_kselftest *tst,
++    const char *module_name)
++{
++	return -ENOSYS;
++}
++
++int
++igt_kselftest_begin(struct igt_kselftest *tst)
++{
++	return -ENOSYS;
++}
++
++void
++igt_kselftest_get_tests(struct kmod_module *kmod,
++    const char *filter,
++    struct igt_list_head *tests)
++{
++}
++
++int
++igt_kselftest_execute(struct igt_kselftest *tst,
++    struct igt_kselftest_list *tl,
++    const char *module_options,
++    const char *result)
++{
++	return -ENOSYS;
++}
++
++void
++igt_kselftest_end(struct igt_kselftest *tst)
++{
++}
++
++void
++igt_kselftest_fini(struct igt_kselftest *tst)
++{
++}
++#endif /* __linux__ */
diff --git a/graphics/igt-gpu-tools/files/patch-lib_igt__kmod.h b/graphics/igt-gpu-tools/files/patch-lib_igt__kmod.h
new file mode 100644
index 000000000000..0714358f05d6
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_igt__kmod.h
@@ -0,0 +1,12 @@
+--- lib/igt_kmod.h.orig	2022-08-31 20:00:01 UTC
++++ lib/igt_kmod.h
+@@ -24,7 +24,9 @@
+ #ifndef IGT_KMOD_H
+ #define IGT_KMOD_H
+ 
++#ifdef __linux__
+ #include <libkmod.h>
++#endif
+ 
+ #include "igt_list.h"
+ 
diff --git a/graphics/igt-gpu-tools/files/patch-lib_igt__kms.c b/graphics/igt-gpu-tools/files/patch-lib_igt__kms.c
new file mode 100644
index 000000000000..35efd4de24aa
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_igt__kms.c
@@ -0,0 +1,13 @@
+--- lib/igt_kms.c.orig	2022-08-31 20:00:01 UTC
++++ lib/igt_kms.c
+@@ -43,6 +43,10 @@
+ #include <sys/kd.h>
+ #endif
+ 
++#ifdef __FreeBSD__
++#include <sys/consio.h>
++#endif
++
+ #include <libudev.h>
+ #include <poll.h>
+ #include <errno.h>
diff --git a/graphics/igt-gpu-tools/files/patch-lib_igt__os.c b/graphics/igt-gpu-tools/files/patch-lib_igt__os.c
new file mode 100644
index 000000000000..902dba8cb6e0
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_igt__os.c
@@ -0,0 +1,42 @@
+--- lib/igt_os.c.orig	2022-08-31 20:00:01 UTC
++++ lib/igt_os.c
+@@ -44,6 +44,9 @@
+ #include <sys/sysinfo.h>
+ #elif defined(HAVE_SWAPCTL) /* Solaris */
+ #include <sys/swap.h>
++#elif defined(__FreeBSD__)
++#include <sys/sysctl.h>
++#include <sys/types.h>
+ #endif
+ #include <sys/resource.h>
+ 
+@@ -148,6 +151,15 @@ igt_get_avail_ram_mb(void)
+ 	npages = sysconf(_SC_AVPHYS_PAGES);
+ 
+ 	retval = (uint64_t) pagesize * npages;
++#elif defined(__FreeBSD__) /* FreeBSD */
++	uint64_t npages, pagesize;
++	size_t npages_len = sizeof(npages);
++	size_t pagesize_len = sizeof(pagesize);
++
++	sysctlbyname("vm.stats.vm.v_free_count", &npages, &npages_len, NULL, 0);
++	sysctlbyname("vm.stats.vm.v_page_size", &pagesize, &pagesize_len, NULL, 0);
++
++	retval = pagesize * npages;
+ #else
+ #error "Unknown how to get available RAM for this OS"
+ #endif
+@@ -210,6 +222,13 @@ igt_get_total_swap_mb(void)
+ 	free(buf);
+ 
+ 	retval = (uint64_t) pagesize * totalpages;
++#elif defined(__FreeBSD__) /* FreeBSD */
++	uint64_t swap_total;
++	size_t swap_total_len = sizeof(swap_total);
++
++	sysctlbyname("vm.swap_total", &swap_total, &swap_total_len, NULL, 0);
++
++	retval = swap_total;
+ #else
+ #warning "Unknown how to get swap size for this OS"
+ 	return 0;
diff --git a/graphics/igt-gpu-tools/files/patch-lib_igt__perf.c b/graphics/igt-gpu-tools/files/patch-lib_igt__perf.c
new file mode 100644
index 000000000000..c1fadfe1b86f
--- /dev/null
+++ b/graphics/igt-gpu-tools/files/patch-lib_igt__perf.c
@@ -0,0 +1,78 @@
+--- lib/igt_perf.c.orig	2022-08-31 20:00:01 UTC
++++ lib/igt_perf.c
+@@ -4,13 +4,16 @@
+ #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>
+ 
+ #include "igt_perf.h"
+ 
++#ifdef __linux__
+ static char *bus_address(int i915, char *path, int pathlen)
+ {
+ 	struct stat st;
+@@ -157,3 +160,58 @@ int igt_perf_open_group(uint64_t type, uint64_t config
+ 	return _perf_open(type, config, group,
+ 			  PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP);
+ }
++#elif defined(__FreeBSD__)
++uint64_t
++igt_perf_type_id(const char *device)
++{
++	return -ENOSYS;
++}
++
++int
++igt_perf_open(uint64_t type, uint64_t config)
++{
++	return -ENOSYS;
++}
++
++int
++igt_perf_open_group(uint64_t type, uint64_t config, int group)
++{
++	return -ENOSYS;
++}
++
++const char *
++i915_perf_device(int i915, char *buf, int buflen)
++{
*** 2388 LINES SKIPPED ***



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