Skip to contentSkip to conversation

Add FreeBSD Support

PATCH In review D Scott Phillips 5 participants 37 messages Dec 11, 2019 – Dec 27, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Add FreeBSD Support

FreeBSD maintains a port of drm and a few drivers: amdgpu, i915, radeon, vboxvideo, vmwgfx:

https://github.com/FreeBSDDesktop/kms-drm/

Recently I backported some drm & i915 security patches into our tree and was lacking a way to verify the backports. Here is my attempt at adding FreeBSD support to igt.

I've tried to order the series so that what I believe will be less controversial comes nearer the start. I've also tried to err on the side of too many small patches, so I'm happy to squash things where that seems more appropriate to people.

The "null" implementations toward the end are probably more like RFC ideas. I'm willing to take other approaches there if anyone has a better idea for how to handle large sections of code that are more linux specific. Cheers,

Scott

D Scott Phillips (30):
Remove unused includes
lib/igt_chipset: Add missing libdrm dependency lib/igt_core: update longjmp buffers to type sigjmp_buf Include <sys/wait.h>, <limits.h>, and <signal.h> where appropriate Use /bin/sh for shell scripts
tools/intel_gpu_top: Use POSIX signal handler type definition
kms_atomic: change PAGE_SIZE to page_size
lib: remove open-coded card index fetching
igt: replace mmap64() with mmap()
drm-uapi: patch sync_file.h to depend on drm.h i915/pm_backlight: use POSIX basename
Include linux specific headers only on linux lib/igt_core: skip oom_adjustments on non-linux platforms i915/gem: Omit linux-specific madvise, mmap, and sched flags on
non-linux
lib/igt_aux: add null implementation
lib/igt_kmod: add null implementation
lib/igt_perf: add null implementation
runner: Add support for non-linux operating systems
Use ETIMEDOUT in place of ETIME on FreeBSD
ilog2: Use libc provided fls() on FreeBSD
lib: undefine FreeBSD libc's ALIGN macro
lib: Add FreeBSD-specific pthread logic
lib/igt_kms: Add FreeBSD support
lib/ioctl_wrappers: Support FreeBSD in igt_require_gem lib/intel_os: Implement get_avail_ram and get_total_swap for FreeBSD lib/igt_device: Implement get_card_index for FreeBSD lib/igt_debugfs: Implement mount() for FreeBSD
build: Add support for building on non-linux
fixup! igt: replace mmap64() with mmap() lib/igt_device_scan: add null implementation

 benchmarks/gem_syslatency.c          |   2 -
 benchmarks/ilog2.h                   |   2 +
 benchmarks/meson.build               |   7 +-
 include/drm-uapi/sync_file.h         |   3 +-
 lib/drmtest.h                        |   4 +
 lib/i915/gem_mman.c                  |   2 +-
 lib/igt.h                            |   4 +
 lib/igt_aux.h                        |   7 ++
 lib/igt_aux_null.c                   | 139 +++++++++++++++++++++++++++
 lib/igt_core.c                       |   7 +-
 lib/igt_core.h                       |   4 +-
 lib/igt_debugfs.c                    |  31 +++---
 lib/igt_device.c                     |  22 +++++
 lib/igt_device_scan_null.c           |  67 +++++++++++++
 lib/igt_eld.c                        |   1 +
 lib/igt_kmod.h                       |   2 +
 lib/igt_kmod_null.c                  |  84 ++++++++++++++++
 lib/igt_kms.c                        |   9 ++
 lib/igt_perf.h                       |  23 +++++
 lib/igt_perf_null.c                  |  45 +++++++++
 lib/igt_sysfs.c                      |  12 ++-
 lib/igt_vgem.c                       |   2 +-
 lib/intel_os.c                       |  16 +++
 lib/ioctl_wrappers.c                 |   6 +-
 lib/meson.build                      |  31 +++++-
 lib/sw_sync.c                        |   1 +
 lib/tests/igt_describe.c             |   1 +
 lib/tests/igt_dynamic_subtests.c     |   1 +
 lib/tests/igt_exit_handler.c         |   1 +
 lib/tests/igt_fork.c                 |   1 +
 lib/tests/igt_invalid_subtest_name.c |   1 +
 lib/tests/igt_no_exit.c              |   1 +
 lib/tests/igt_tests_common.h         |   1 +
 man/rst2man.sh                       |   2 +-
 meson.build                          |  10 +-
 runner/executor.c                    |  28 +++++-
 runner/job_list.c                    |   3 +
 tests/generate_testlist.sh           |   6 +-
 tests/i915/gem_close_race.c          |   2 +
 tests/i915/gem_concurrent_all.c      |   7 +-
 tests/i915/gem_ctx_persistence.c     |   2 +-
 tests/i915/gem_exec_fence.c          |   1 +
 tests/i915/gem_exec_latency.c        |   5 +-
 tests/i915/gem_mmap_gtt.c            |  22 ++---
 tests/i915/gem_mmap_offset.c         |  18 ++--
 tests/i915/gem_reloc_overflow.c      |   1 -
 tests/i915/gem_shrink.c              |   5 +-
 tests/i915/i915_pm_backlight.c       |   1 +
 tests/kms_atomic.c                   |  14 +--
 tests/meson.build                    |  30 ++++--
 tests/perf.c                         |   1 +
 tools/aubdump.c                      |   2 +
 tools/intel_gpu_top.c                |   2 +-
 tools/intel_gvtg_test.c              |   1 +
 tools/meson.build                    |  12 ++-
 55 files changed, 624 insertions(+), 91 deletions(-)
 create mode 100644 lib/igt_aux_null.c
 create mode 100644 lib/igt_device_scan_null.c
 create mode 100644 lib/igt_kmod_null.c
 create mode 100644 lib/igt_perf_null.c
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw

PATCH 1/29 Remove unused includes

<linux/unistd.h> and <malloc.h> are not needed and are not available on other platforms.

---
 benchmarks/gem_syslatency.c     | 2 --
 tests/i915/gem_reloc_overflow.c | 1 -
 2 files changed, 3 deletions(-)
benchmarks/gem_syslatency.c +0 -2
index 40230630..30722d85 100644
@@ -42,8 +42,6 @@
 #include <limits.h>
 #include "drm.h"
 
-#include <linux/unistd.h>
-
 #define sigev_notify_thread_id _sigev_un._tid
 
 static volatile int done;
tests/i915/gem_reloc_overflow.c +0 -1
index c9d1f207..75af2659 100644
@@ -37,7 +37,6 @@
 #include <inttypes.h>
 #include <errno.h>
 #include <unistd.h>
-#include <malloc.h>
 #include <limits.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#2 lore raw

PATCH 2/29 lib/igt_chipset: Add missing libdrm dependency

In reply to D Scott Phillips

Without this the build fails because it can not find xf86drm.h.

---
 lib/meson.build | 1 +
 1 file changed, 1 insertion(+)
lib/meson.build +1 -0
index 57eb7d93..25ea62d5 100644
@@ -154,6 +154,7 @@ igt_deps = [ lib_igt ] + lib_deps
 lin_igt_chipset_build = static_library('igt_chipset',
                                        ['intel_chipset.c',
                                         'intel_device_info.c'],
+                                       dependencies : libdrm,
                                        include_directories : inc)
 
 lib_igt_chipset = declare_dependency(link_with : lin_igt_chipset_build,
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#3 lore raw

PATCH 3/29 lib/igt_core: update longjmp buffers to type sigjmp_buf

In reply to D Scott Phillips

sigsetjmp/siglongjmp operate on a different type from setjmp/longjmp, sigjmp_buf vs jmp_buf. On glibc these happen to be the same type, but on other platforms they may be different.

---
 lib/igt_core.c | 2 +-
 lib/igt_core.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
lib/igt_core.c +1 -1
index c705be1e..09d8c159 100644
@@ -1328,7 +1328,7 @@ static void exit_subtest(const char *result)
 	const char *subtest_text = in_dynamic_subtest ? "Dynamic subtest" : "Subtest";
 	const char **subtest_name = in_dynamic_subtest ? &in_dynamic_subtest : &in_subtest;
 	struct timespec *thentime = in_dynamic_subtest ? &dynamic_subtest_time : &subtest_time;
-	jmp_buf *jmptarget = in_dynamic_subtest ? &igt_dynamic_jmpbuf : &igt_subtest_jmpbuf;
+	sigjmp_buf *jmptarget = in_dynamic_subtest ? &igt_dynamic_jmpbuf : &igt_subtest_jmpbuf;
 
 	igt_gettime(&now);
 
lib/igt_core.h +2 -2
index c17a7ba8..e99b782f 100644
@@ -145,8 +145,8 @@ void __igt_fixture_end(void) __attribute__((noreturn));
 			 __igt_fixture_complete())
 
 /* subtest infrastructure */
-jmp_buf igt_subtest_jmpbuf;
-jmp_buf igt_dynamic_jmpbuf;
+sigjmp_buf igt_subtest_jmpbuf;
+sigjmp_buf igt_dynamic_jmpbuf;
 typedef int (*igt_opt_handler_t)(int opt, int opt_index, void *data);
 #define IGT_OPT_HANDLER_SUCCESS 0
 #define IGT_OPT_HANDLER_ERROR -2
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#4 lore raw

PATCH 4/29 Include <sys/wait.h>, <limits.h>, and <signal.h> where appropriate

In reply to D Scott Phillips

On FreeBSD, sys/wait.h is needed for WIFEXITED and friends, limits.h is needed for PATH_MAX, and signal.h is needed for SIGTERM and friends.

---
 lib/igt_eld.c                        | 1 +
 lib/tests/igt_describe.c             | 1 +
 lib/tests/igt_dynamic_subtests.c     | 1 +
 lib/tests/igt_exit_handler.c         | 1 +
 lib/tests/igt_fork.c                 | 1 +
 lib/tests/igt_invalid_subtest_name.c | 1 +
 lib/tests/igt_no_exit.c              | 1 +
 lib/tests/igt_tests_common.h         | 1 +
 runner/job_list.c                    | 1 +
 tests/i915/gem_exec_fence.c          | 1 +
 tests/perf.c                         | 1 +
 tools/intel_gvtg_test.c              | 1 +
 12 files changed, 12 insertions(+)
lib/igt_eld.c +1 -0
index ef6625df..d3144851 100644
@@ -28,6 +28,7 @@
 #include <dirent.h>
 #include <errno.h>
 #include <glob.h>
+#include <limits.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <string.h>
lib/tests/igt_describe.c +1 -0
index 6f3a4319..d1103954 100644
@@ -22,6 +22,7 @@
  */
 
 #include <sys/wait.h>
+#include <signal.h>
 #include <string.h>
 #include <stdlib.h>
 
lib/tests/igt_dynamic_subtests.c +1 -0
index 606104c5..8740827e 100644
@@ -23,6 +23,7 @@
 
 #include <errno.h>
 #include <sys/wait.h>
+#include <signal.h>
 
 #include "igt_core.h"
 #include "drmtest.h"
lib/tests/igt_exit_handler.c +1 -0
index 892a7f14..c1219e6b 100644
@@ -25,6 +25,7 @@
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <signal.h>
 #include "igt_core.h"
 #include "drmtest.h"
 
lib/tests/igt_fork.c +1 -0
index 7e8b4f9b..a25f2edc 100644
@@ -23,6 +23,7 @@
  */
 
 #include <errno.h>
+#include <signal.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <unistd.h>
lib/tests/igt_invalid_subtest_name.c +1 -0
index 92e767ab..ed78a90c 100644
@@ -23,6 +23,7 @@
 
 #include <errno.h>
 #include <sys/wait.h>
+#include <signal.h>
 
 #include "igt_core.h"
 #include "drmtest.h"
lib/tests/igt_no_exit.c +1 -0
index 82f00b52..58131828 100644
@@ -26,6 +26,7 @@
  */
 
 #include <sys/wait.h>
+#include <signal.h>
 
 #include "drmtest.h"
 
lib/tests/igt_tests_common.h +1 -0
index e66ee37c..9b98e256 100644
@@ -25,6 +25,7 @@
 #ifndef IGT_LIB_TESTS_COMMON_H
 #define IGT_LIB_TESTS_COMMON_H
 
+#include <sys/wait.h>
 #include <assert.h>
 
 /*
runner/job_list.c +1 -0
index 93cede75..bc10a1bf 100644
@@ -7,6 +7,7 @@
 #include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <sys/wait.h>
 #include <unistd.h>
 
 #include "job_list.h"
tests/i915/gem_exec_fence.c +1 -0
index 0fc7301a..dc32967f 100644
@@ -31,6 +31,7 @@
 #include <sys/ioctl.h>
 #include <sys/poll.h>
 #include <sys/signal.h>
+#include <signal.h>
 
 IGT_TEST_DESCRIPTION("Check that execbuf waits for explicit fences");
 
tests/perf.c +1 -0
index f5dd6051..e6b77b0d 100644
@@ -33,6 +33,7 @@
 #include <sys/time.h>
 #include <sys/times.h>
 #include <sys/types.h>
+#include <sys/wait.h>
 #include <dirent.h>
 #include <time.h>
 #include <poll.h>
tools/intel_gvtg_test.c +1 -0
index ad5ee6a6..ec185885 100644
@@ -44,6 +44,7 @@
 #include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/wait.h>
 #include <string.h>
 #include <stdlib.h>
 #include <signal.h>
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#5 lore raw

PATCH 5/29 Use /bin/sh for shell scripts

In reply to D Scott Phillips

These scripts don't use an bash-specific functionality, and bsd is not available by default on FreeBSD.

---
 man/rst2man.sh             | 2 +-
 tests/generate_testlist.sh | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
man/rst2man.sh +1 -1
index 49a98fc5..b7f28991 100755
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 rst2man=$1
 input=$2
tests/generate_testlist.sh +3 -3
index 87637fc8..d506b149 100755
@@ -1,16 +1,16 @@
-#!/bin/bash
+#!/bin/sh
 
 OUTPUT=$1
 shift
 
 echo TESTLIST > $OUTPUT
 
-if [[ $# -gt 0 ]] ; then
+if [ $# -gt 0 ] ; then
 	echo -n $1 >> $OUTPUT
 	shift
 fi
 
-while [[ $# -gt 0 ]] ; do
+while [ $# -gt 0 ] ; do
 	echo -n " $1" >> $OUTPUT
 	shift
 done
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#6 lore raw

PATCH 6/29 tools/intel_gpu_top: Use POSIX signal handler type definition

In reply to D Scott Phillips

The type sighandler_t is a GNU extension which isn't available on FreeBSD, where it instead follows the POSIX specification of a raw function pointer type.

---
 tools/intel_gpu_top.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/intel_gpu_top.c +1 -1
index cc8db7c5..2ea484cf 100644
@@ -1299,7 +1299,7 @@ int main(int argc, char **argv)
 	}
 
 	if (output_mode != INTERACTIVE) {
-		sighandler_t sig = signal(SIGINT, sigint_handler);
+		void (* sig)(int) = signal(SIGINT, sigint_handler);
 
 		if (sig == SIG_ERR)
 			fprintf(stderr, "Failed to install signal handler!\n");
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#7 lore raw

PATCH 7/29 kms_atomic: change `PAGE_SIZE` to `page_size`

In reply to D Scott Phillips

POSIX limit.h provides a PAGE_SIZE constant, so change the variable name here to not collide with it.

---
 tests/kms_atomic.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
tests/kms_atomic.c +7 -7
index 8462d128..ade777e3 100644
@@ -683,7 +683,7 @@ static void crtc_invalid_params_fence(igt_pipe_t *pipe,
 {
 	int timeline, fence_fd;
 	void *map;
-	const ptrdiff_t PAGE_SIZE = sysconf(_SC_PAGE_SIZE);
+	const ptrdiff_t page_size = sysconf(_SC_PAGE_SIZE);
 	uint64_t old_mode_id = pipe->values[IGT_CRTC_MODE_ID];
 
 	igt_require_sw_sync();
@@ -691,28 +691,28 @@ static void crtc_invalid_params_fence(igt_pipe_t *pipe,
 	timeline = sw_sync_timeline_create();
 
 	/* invalid out_fence_ptr */
-	map = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+	map = mmap(NULL, page_size, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
 	igt_assert(map != MAP_FAILED);
 
 	igt_pipe_obj_set_prop_value(pipe, IGT_CRTC_OUT_FENCE_PTR, (ptrdiff_t)map);
 	crtc_commit_atomic_err(pipe, plane, ATOMIC_RELAX_NONE, EFAULT);
-	munmap(map, PAGE_SIZE);
+	munmap(map, page_size);
 
 	/* invalid out_fence_ptr */
-	map = mmap(NULL, PAGE_SIZE, PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+	map = mmap(NULL, page_size, PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
 	igt_assert(map != MAP_FAILED);
 
 	igt_pipe_obj_set_prop_value(pipe, IGT_CRTC_OUT_FENCE_PTR, (ptrdiff_t)map);
 	crtc_commit_atomic_err(pipe, plane, ATOMIC_RELAX_NONE, EFAULT);
-	munmap(map, PAGE_SIZE);
+	munmap(map, page_size);
 
 	/* invalid out_fence_ptr */
-	map = mmap(NULL, PAGE_SIZE, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+	map = mmap(NULL, page_size, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
 	igt_assert(map != MAP_FAILED);
 
 	igt_pipe_obj_set_prop_value(pipe, IGT_CRTC_OUT_FENCE_PTR, (ptrdiff_t)map);
 	crtc_commit_atomic_err(pipe, plane, ATOMIC_RELAX_NONE, EFAULT);
-	munmap(map, PAGE_SIZE);
+	munmap(map, page_size);
 
 	/* valid in fence but not allowed prop on crtc */
 	fence_fd = sw_sync_timeline_create_fence(timeline, 1);
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#8 lore raw

PATCH 8/29 lib: remove open-coded card index fetching

In reply to D Scott Phillips

Replace open-coded card index fetching via stat with igt_device_get_card_index() calls.

---
 lib/igt_debugfs.c | 17 ++++-------------
 lib/igt_sysfs.c   | 10 +++++-----
 2 files changed, 9 insertions(+), 18 deletions(-)
lib/igt_debugfs.c +4 -13
index 676884c8..34b2e4ee 100644
@@ -41,6 +41,7 @@
 #include "igt_aux.h"
 #include "igt_kms.h"
 #include "igt_debugfs.h"
+#include "igt_device.h"
 #include "igt_sysfs.h"
 
 /**
@@ -164,20 +165,10 @@ char *igt_debugfs_path(int device, char *path, int pathlen)
 	debugfs_root = igt_debugfs_mount();
 	igt_assert(debugfs_root);
 
-	memset(&st, 0, sizeof(st));
-	if (device != -1) { /* if no fd, we presume we want dri/0 */
-		if (fstat(device, &st)) {
-			igt_debug("Couldn't stat FD for DRM device: %m\n");
-			return NULL;
-		}
-
-		if (!S_ISCHR(st.st_mode)) {
-			igt_debug("FD for DRM device not a char device!\n");
-			return NULL;
-		}
-	}
+	idx = 0;
+	if (device >= 0)
+		idx = igt_device_get_card_index(device);
 
-	idx = minor(st.st_rdev);
 	snprintf(path, pathlen, "%s/dri/%d/name", debugfs_root, idx);
 	if (stat(path, &st))
 		return NULL;
lib/igt_sysfs.c +5 -5
index 7528c3bd..61293a4e 100644
@@ -43,6 +43,8 @@
 #include "igt_sysfs.h"
 #include "igt_device.h"
 
+#define DRM_MAJOR 226
+
 /**
  * SECTION:igt_sysfs
  * @short_description: Support code for sysfs features
@@ -98,16 +100,14 @@ static int writeN(int fd, const char *buf, int len)
  */
 char *igt_sysfs_path(int device, char *path, int pathlen)
 {
-	struct stat st;
+	int idx;
 
 	if (device < 0)
 		return NULL;
 
-	if (fstat(device, &st) || !S_ISCHR(st.st_mode))
-		return NULL;
+	idx = igt_device_get_card_index(device);
 
-	snprintf(path, pathlen, "/sys/dev/char/%d:%d",
-		 major(st.st_rdev), minor(st.st_rdev));
+	snprintf(path, pathlen, "/sys/dev/char/%d:%d", DRM_MAJOR, idx);
 
 	if (access(path, F_OK))
 		return NULL;
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#9 lore raw

PATCH 9/29 igt: replace mmap64() with mmap()

In reply to D Scott Phillips

mmap64 is the variant syscall with 64-bit off_t. On 64-bit platforms mmap == mmap64. On 32-bit platforms mmap == mmap64 when _FILE_OFFSET_BITS=64, which we get with AC_SYS_LARGEFILE in autoconf and by default with meson. Other platforms don't necessarily have an mmap64 syscall or function.

---
 lib/i915/gem_mman.c          |  2 +-
 lib/igt_vgem.c               |  2 +-
 tests/i915/gem_mmap_gtt.c    | 22 +++++++++++-----------
 tests/i915/gem_mmap_offset.c | 18 +++++++++---------
 4 files changed, 22 insertions(+), 22 deletions(-)
lib/i915/gem_mman.c +1 -1
index 6256627b..056f9382 100644
@@ -62,7 +62,7 @@ void *__gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot)
 	if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg))
 		return NULL;
 
-	ptr = mmap64(0, size, prot, MAP_SHARED, fd, mmap_arg.offset);
+	ptr = mmap(0, size, prot, MAP_SHARED, fd, mmap_arg.offset);
 	if (ptr == MAP_FAILED)
 		ptr = NULL;
 	else
lib/igt_vgem.c +1 -1
index 7f933b23..468383c7 100644
@@ -76,7 +76,7 @@ void *__vgem_mmap(int fd, struct vgem_bo *bo, unsigned prot)
 	if (drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg))
 		return NULL;
 
-	ptr = mmap64(0, bo->size, prot, MAP_SHARED, fd, arg.offset);
+	ptr = mmap(0, bo->size, prot, MAP_SHARED, fd, arg.offset);
 	if (ptr == MAP_FAILED)
 		return NULL;
 
tests/i915/gem_mmap_gtt.c +11 -11
index af87ebc3..cd6ab489 100644
@@ -103,11 +103,11 @@ test_access(int fd)
 	mmap_arg.handle = handle;
 	do_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg);
 
-	igt_assert(mmap64(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,
+	igt_assert(mmap(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,
 			  MAP_SHARED, fd, mmap_arg.offset));
 
 	/* Check that the same offset on the other fd doesn't work. */
-	igt_assert(mmap64(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,
+	igt_assert(mmap(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,
 			  MAP_SHARED, fd2, mmap_arg.offset) == MAP_FAILED);
 	igt_assert(errno == EACCES);
 
@@ -118,7 +118,7 @@ test_access(int fd)
 
 	/* Recheck that it works after flink. */
 	/* Check that the same offset on the other fd doesn't work. */
-	igt_assert(mmap64(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,
+	igt_assert(mmap(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,
 			  MAP_SHARED, fd2, mmap_arg.offset));
 }
 
@@ -149,11 +149,11 @@ test_short(int fd)
 	for (pages = 1; pages <= OBJECT_SIZE / PAGE_SIZE; pages <<= 1) {
 		uint8_t *r, *w;
 
-		w = mmap64(0, pages * PAGE_SIZE, PROT_READ | PROT_WRITE,
+		w = mmap(0, pages * PAGE_SIZE, PROT_READ | PROT_WRITE,
 			   MAP_SHARED, fd, mmap_arg.offset);
 		igt_assert(w != MAP_FAILED);
 
-		r = mmap64(0, pages * PAGE_SIZE, PROT_READ,
+		r = mmap(0, pages * PAGE_SIZE, PROT_READ,
 			   MAP_SHARED, fd, mmap_arg.offset);
 		igt_assert(r != MAP_FAILED);
 
@@ -371,13 +371,13 @@ test_isolation(int i915)
 
 	close(B);
 
-	ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);
+	ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);
 	igt_assert(ptr != MAP_FAILED);
 	munmap(ptr, 4096);
 
 	close(A);
 
-	ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);
+	ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);
 	igt_assert(ptr == MAP_FAILED);
 }
 
@@ -387,7 +387,7 @@ test_close_race(int i915)
 	const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
 	_Atomic uint32_t *handles;
 
-	handles = mmap64(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+	handles = mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
 	igt_assert(handles != MAP_FAILED);
 
 	igt_fork(child, ncpus + 1) {
@@ -405,7 +405,7 @@ test_close_race(int i915)
 				  &mmap_arg) != -1) {
 				void *ptr;
 
-				ptr = mmap64(0, 4096,
+				ptr = mmap(0, 4096,
 					     PROT_WRITE, MAP_SHARED, i915,
 					     mmap_arg.offset);
 				if (ptr != MAP_FAILED) {
@@ -431,7 +431,7 @@ test_flink_race(int i915)
 	const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
 	_Atomic uint32_t *handles;
 
-	handles = mmap64(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+	handles = mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
 	igt_assert(handles != MAP_FAILED);
 
 	igt_fork(child, ncpus + 1) {
@@ -456,7 +456,7 @@ test_flink_race(int i915)
 				  &mmap_arg) != -1) {
 				void *ptr;
 
-				ptr = mmap64(0, 4096,
+				ptr = mmap(0, 4096,
 					     PROT_WRITE, MAP_SHARED, fd,
 					     mmap_arg.offset);
 				if (ptr != MAP_FAILED) {
tests/i915/gem_mmap_offset.c +9 -9
index 95e1e3e6..277ffd83 100644
@@ -76,7 +76,7 @@ __mmap_offset(int i915, uint32_t handle, uint64_t offset, uint64_t size,
 	if (mmap_offset_ioctl(i915, &arg))
 		return NULL;
 
-	ptr = mmap64(0, size, prot, MAP_SHARED, i915, arg.offset + offset);
+	ptr = mmap(0, size, prot, MAP_SHARED, i915, arg.offset + offset);
 	if (ptr == MAP_FAILED)
 		ptr = NULL;
 	else
@@ -224,34 +224,34 @@ static void isolation(int i915)
 			 t->name, B, b, offset_b);
 
 		errno = 0;
-		ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, i915, offset_a);
+		ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, i915, offset_a);
 		igt_assert(ptr == MAP_FAILED);
 		igt_assert_eq(errno, EACCES);
 
 		errno = 0;
-		ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, i915, offset_b);
+		ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, i915, offset_b);
 		igt_assert(ptr == MAP_FAILED);
 		igt_assert_eq(errno, EACCES);
 
 		errno = 0;
-		ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, B, offset_a);
+		ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, B, offset_a);
 		igt_assert(ptr == MAP_FAILED);
 		igt_assert_eq(errno, EACCES);
 
 		errno = 0;
-		ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, A, offset_b);
+		ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, A, offset_b);
 		igt_assert(ptr == MAP_FAILED);
 		igt_assert_eq(errno, EACCES);
 
 		close(B);
 
-		ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);
+		ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);
 		igt_assert(ptr != MAP_FAILED);
 		munmap(ptr, 4096);
 
 		close(A);
 
-		ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);
+		ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);
 		igt_assert(ptr == MAP_FAILED);
 	}
 }
@@ -286,7 +286,7 @@ static void close_race(int i915, int timeout)
 	_Atomic uint32_t *handles;
 	size_t len = ALIGN((ncpus + 1) * sizeof(uint32_t), 4096);
 
-	handles = mmap64(0, len, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+	handles = mmap(0, len, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
 	igt_assert(handles != MAP_FAILED);
 
 	igt_fork(child, ncpus + 1) {
@@ -305,7 +305,7 @@ static void close_race(int i915, int timeout)
 				  &mmap_arg) != -1) {
 				void *ptr;
 
-				ptr = mmap64(0, 4096,
+				ptr = mmap(0, 4096,
 					     PROT_WRITE, MAP_SHARED, i915,
 					     mmap_arg.offset);
 				if (ptr != MAP_FAILED) {
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#10 lore raw

PATCH 10/29 drm-uapi: patch sync_file.h to depend on drm.h

In reply to D Scott Phillips

linux/sync_file.h isn't strictly part of the drm uapi and so doesn't include drm.h. drm.h contains some compatibility #defines for non-Linux platforms for things like __u32 which synf_file needs.

---
 include/drm-uapi/sync_file.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
include/drm-uapi/sync_file.h +1 -2
index b4f2db00..4713b5b9 100644
@@ -12,8 +12,7 @@
 #ifndef _LINUX_SYNC_H
 #define _LINUX_SYNC_H
 
-#include <linux/ioctl.h>
-#include <linux/types.h>
+#include "drm.h"
 
 /**
  * struct sync_merge_data - data passed to merge ioctl
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#11 lore raw

Re: [igt-dev] [PATCH i-g-t 10/29] drm-uapi: patch sync_file.h to depend on drm.h

Quoted 4 lines · D Scott Phillips

linux/sync_file.h isn't strictly part of the drm uapi and so doesn't include drm.h. drm.h contains some compatibility #defines for non-Linux platforms for things like __u32 which synf_file needs.

Unfortunately, stuff in drm-uapi are supposed to be verbatim copies from the kernel.

BR,
Jani.

Quoted 20 lines
---
 include/drm-uapi/sync_file.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
include/drm-uapi/sync_file.h +1 -2
index b4f2db00..4713b5b9 100644
@@ -12,8 +12,7 @@
 #ifndef _LINUX_SYNC_H
 #define _LINUX_SYNC_H
 
-#include <linux/ioctl.h>
-#include <linux/types.h>
+#include "drm.h"
 
 /**
  * struct sync_merge_data - data passed to merge ioctl
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#12 lore raw

PATCH 11/29 i915/pm_backlight: use POSIX basename

In reply to D Scott Phillips

We can get POSIX basename by including libgen.h. It behaves slightly differently from GNU basename, like possibly modifying the passed in string. This is OK in this usage, and POSIX basename is available on other platforms.

---
 tests/i915/i915_pm_backlight.c | 1 +
 1 file changed, 1 insertion(+)
tests/i915/i915_pm_backlight.c +1 -0
index 83b1ed68..2f65156f 100644
@@ -30,6 +30,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <libgen.h>
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#13 lore raw

Re: [igt-dev] [PATCH i-g-t 11/29] i915/pm_backlight: use POSIX basename

Quoted 15 lines · D Scott Phillips

We can get POSIX basename by including libgen.h. It behaves slightly differently from GNU basename, like possibly modifying the passed in string. This is OK in this usage, and POSIX basename is available on other platforms.

---
 tests/i915/i915_pm_backlight.c | 1 +
 1 file changed, 1 insertion(+)
tests/i915/i915_pm_backlight.c +0 -0
index 83b1ed68..2f65156f 100644

tests/i915/i915_pm_backlight.c line 33

Quoted 4 lines
tests/i915/i915_pm_backlight.c +1 -0
@@ -30,6 +30,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <libgen.h>

Needs to be wrapped in #ifdef HAVE_LIBGEN_H though.

Signature · 5 lines
Petri Latvala
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#14 lore raw

PATCH 12/29 Include Linux specific headers only on Linux

In reply to D Scott Phillips

Include Linux specific headers like sys/sysmacros.h or linux/limits.h with a defined(__linux__) guard, for compatibility with other platforms.

---
 lib/igt_debugfs.c | 2 ++
 lib/igt_device.c  | 2 ++
 lib/igt_sysfs.c   | 2 ++
 runner/job_list.c | 2 ++
 tools/aubdump.c   | 2 ++
 5 files changed, 10 insertions(+)
lib/igt_debugfs.c +2 -0
index 34b2e4ee..5a9c8c3c 100644
@@ -25,7 +25,9 @@
 #include <inttypes.h>
 #include <sys/stat.h>
 #include <sys/mount.h>
+#if defined(__linux__)
 #include <sys/sysmacros.h>
+#endif
 #include <dirent.h>
 #include <errno.h>
 #include <stdio.h>
lib/igt_device.c +2 -0
index 07bb0a0d..01a9eff4 100644
@@ -25,7 +25,9 @@
 #include <fcntl.h>
 
 #include <sys/stat.h>
+#if defined(__linux__)
 #include <sys/sysmacros.h>
+#endif
 #include "igt.h"
 #include "igt_device.h"
 #include "igt_sysfs.h"
lib/igt_sysfs.c +2 -0
index 61293a4e..5b3f817c 100644
@@ -24,7 +24,9 @@
 
 #include <inttypes.h>
 #include <sys/stat.h>
+#if defined(__linux__)
 #include <sys/sysmacros.h>
+#endif
 #include <sys/mount.h>
 #include <errno.h>
 #include <stdarg.h>
runner/job_list.c +2 -0
index bc10a1bf..8014a58c 100644
@@ -1,7 +1,9 @@
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
+#if defined(__linux__)
 #include <linux/limits.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
tools/aubdump.c +2 -0
index 00e19712..25c28e62 100644
@@ -30,7 +30,9 @@
 #include <stdarg.h>
 #include <fcntl.h>
 #include <sys/types.h>
+#if defined(__linux__)
 #include <sys/sysmacros.h>
+#endif
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#15 lore raw

PATCH 13/29 lib/igt_core: skip oom_adjustments on non-Linux platforms

In reply to D Scott Phillips

oom_adjustments are available only on Linux. Omit the body of oom_adjust_for_doom on other platforms and just accept whatever default out-of-memory handling we get.

---
 lib/igt_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/igt_core.c +2 -1
index 09d8c159..8df89905 100644
@@ -672,6 +672,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
 
 static void oom_adjust_for_doom(void)
 {
+#if defined(__linux__)
 	int fd;
 	const char always_kill[] = "1000";
 
@@ -679,7 +680,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
 }
 
 /**
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#16 lore raw

PATCH 14/29 i915/gem: Omit Linux-specific madvise, mmap, and sched flags on non-Linux

In reply to D Scott Phillips

These various flags are Linux specific and don't have cross platform equivalents. Accept the different behavior differences on other platforms for now.

---
 tests/i915/gem_concurrent_all.c | 7 +++++--
 tests/i915/gem_exec_latency.c   | 5 ++++-
 tests/i915/gem_shrink.c         | 5 ++++-
 3 files changed, 13 insertions(+), 4 deletions(-)
tests/i915/gem_concurrent_all.c +5 -2
index 6486bebf..bee18637 100644
@@ -1876,8 +1876,11 @@ igt_main
 						pin_sz *= 1024 * 1024;
 
 						if (posix_memalign(&pinned, 4096, pin_sz) ||
-						    mlock(pinned, pin_sz) ||
-						    madvise(pinned, pin_sz, MADV_DONTFORK)) {
+						    mlock(pinned, pin_sz)
+#if defined(__linux__)
+						    || madvise(pinned, pin_sz, MADV_DONTFORK)
+#endif
+						) {
 							free(pinned);
 							pinned = NULL;
 						}
tests/i915/gem_exec_latency.c +4 -1
index 3d99182a..111d71bc 100644
@@ -509,7 +509,10 @@ rthog_latency_on_ring(int fd, unsigned int engine, const char *name, unsigned in
 				{ .sched_priority = 99 };
 
 				ret = sched_setscheduler(0,
-							 SCHED_FIFO | SCHED_RESET_ON_FORK,
+#if defined(__linux__)
+							 SCHED_RESET_ON_FORK |
+#endif
+							 SCHED_FIFO,
 							 &rt);
 				if (ret) {
 					igt_warn("Failed to set scheduling policy!\n");
tests/i915/gem_shrink.c +4 -1
index 11aa9efc..ff4e3f39 100644
@@ -272,7 +272,10 @@ static void leak(int fd, uint64_t alloc)
 	char *ptr;
 
 	ptr = mmap(NULL, alloc, PROT_READ | PROT_WRITE,
-		   MAP_ANON | MAP_PRIVATE | MAP_POPULATE,
+#if defined(__linux__)
+		   MAP_POPULATE |
+#endif
+		   MAP_ANON | MAP_PRIVATE,
 		   -1, 0);
 	if (ptr != (char *)-1)
 		return;
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#17 lore raw

PATCH 15/29 lib/igt_aux: add null implementation

In reply to D Scott Phillips

igt_aux depends on Linux specific functionality like udev, sysfs, and others. Add a do-nothing implementation of the same API for inclusion on other platforms.

---
 lib/igt_aux_null.c | 139 +++++++++++++++++++++++++++++++++++++++++++++
 lib/meson.build    |  11 +++-
 2 files changed, 149 insertions(+), 1 deletion(-)
 create mode 100644 lib/igt_aux_null.c
lib/igt_aux_null.c new file +139 -0
new file mode 100644
index 00000000..b83217e4
@@ -0,0 +1,139 @@
+/*
+ * Copyright © 2019 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#include "igt_aux.h"
+
+void igt_fork_signal_helper(void) {
+}
+
+void igt_stop_signal_helper(void) {
+}
+
+void igt_suspend_signal_helper(void) {
+}
+
+void igt_resume_signal_helper(void) {
+}
+
+void igt_fork_shrink_helper(int fd) {
+}
+
+void igt_stop_shrink_helper(void) {
+}
+
+void igt_fork_hang_detector(int fd) {
+}
+
+void igt_stop_hang_detector(void) {
+}
+
+bool __igt_sigiter_continue(struct __igt_sigiter *iter, bool interrupt) {
+	return false;
+}
+
+void igt_exchange_int(void *array, unsigned i, unsigned j) {
+	igt_swap(((int *)array)[i], ((int *)array)[j]);
+}
+
+void igt_exchange_int64(void *array, unsigned i, unsigned j) {
+	igt_swap(((int64_t *)array)[i], ((int64_t *)array)[j]);
+}
+
+void igt_permute_array(void *array, unsigned size,
+			   void (*exchange_func)(void *array,
+						 unsigned i,
+						 unsigned j)) {
+}
+
+void igt_progress(const char *header, uint64_t i, uint64_t total) {
+}
+
+void igt_print_activity(void) {
+}
+
+bool igt_check_boolean_env_var(const char *env_var, bool default_value) {
+	return false;
+}
+
+bool igt_aub_dump_enabled(void) {
+	return false;
+}
+
+void igt_system_suspend_autoresume(enum igt_suspend_state state,
+				   enum igt_suspend_test test) {
+}
+
+void igt_set_autoresume_delay(int delay_secs) {
+}
+
+int igt_get_autoresume_delay(enum igt_suspend_state state) {
+	return 1;
+}
+
+void igt_drop_root(void) {
+}
+
+void igt_debug_wait_for_keypress(const char *var) {
+}
+
+void igt_debug_manual_check(const char *var, const char *expected) {
+}
+
+void igt_lock_mem(size_t size) {
+}
+
+void igt_unlock_mem(void) {
+}
+
+void igt_start_siglatency(int sig) {
+}
+
+double igt_stop_siglatency(struct igt_mean *result) {
+	return 1.0;
+}
+
+bool igt_allow_unlimited_files(void) {
+	return true;
+}
+
+void igt_set_module_param(const char *name, const char *val) {
+}
+
+void igt_set_module_param_int(const char *name, int val) {
+}
+
+int igt_is_process_running(const char *comm) {
+	return 0;
+}
+
+int igt_terminate_process(int sig, const char *comm) {
+	return 0;
+}
+
+void igt_lsof(const char *dpath) {
+}
+
+uint64_t vfs_file_max(void) {
+	return 1;
+}
lib/meson.build +10 -1
index 25ea62d5..6a56fff0 100644
@@ -11,7 +11,6 @@ lib_sources = [
 	'igt_debugfs.c',
 	'igt_device.c',
 	'igt_device_scan.c',
-	'igt_aux.c',
 	'igt_gt.c',
 	'igt_halffloat.c',
 	'igt_matrix.c',
@@ -67,6 +66,16 @@ lib_sources = [
 	'veboxcopy_gen12.c',
 ]
 
+if host_machine.system() == 'linux'
+	lib_sources += [
+		'igt_aux.c',
+	]
+else
+	lib_sources += [
+		'igt_aux_null.c',
+	]
+endif
+
 lib_deps = [
 	cairo,
 	glib,
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#18 lore raw

PATCH 16/29 lib/igt_kmod: add null implementation

In reply to D Scott Phillips

igt_kmod depends on libkmod, which is only available on Linux. Add a do-nothing implementation of the same API for inclusion on other platforms.

---
 lib/igt_kmod.h      |  2 ++
 lib/igt_kmod_null.c | 84 +++++++++++++++++++++++++++++++++++++++++++++
 lib/meson.build     |  3 +-
 3 files changed, 88 insertions(+), 1 deletion(-)
 create mode 100644 lib/igt_kmod_null.c
lib/igt_kmod.h +2 -0
index c71ec147..cd374609 100644
@@ -24,7 +24,9 @@
 #ifndef IGT_KMOD_H
 #define IGT_KMOD_H
 
+#if defined(__linux__)
 #include <libkmod.h>
+#endif
 
 #include "igt_list.h"
 
lib/igt_kmod_null.c new file +84 -0

84 lines not on this page · raw message

lib/meson.build +2 -1
index 6a56fff0..4a58d9cf 100644
@@ -54,7 +54,6 @@ lib_sources = [
 	'igt_pm.c',
 	'igt_dummyload.c',
 	'uwildmat/uwildmat.c',
-	'igt_kmod.c',
 	'igt_panfrost.c',
 	'igt_v3d.c',
 	'igt_vc4.c',
@@ -69,10 +68,12 @@ lib_sources = [
 if host_machine.system() == 'linux'
 	lib_sources += [
 		'igt_aux.c',
+		'igt_kmod.c',
 	]
 else
 	lib_sources += [
 		'igt_aux_null.c',
+		'igt_kmod_null.c',
 	]
 endif
 
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#19 lore raw

PATCH 17/29 lib/igt_perf: add null implementation

In reply to D Scott Phillips

perf is only availble on Linux. Add a do-nothing implementation of the same API for inclusion on other platforms.

---
 lib/igt_perf.h      | 23 +++++++++++++++++++++++
 lib/igt_perf_null.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 lib/meson.build     | 12 ++++++++++--
 3 files changed, 78 insertions(+), 2 deletions(-)
 create mode 100644 lib/igt_perf_null.c
lib/igt_perf.h +23 -0
index e00718f4..1e27b3cf 100644
@@ -27,10 +27,13 @@
 
 #include <stdint.h>
 
+#if defined(__linux__)
 #include <linux/perf_event.h>
+#endif
 
 #include "igt_gt.h"
 
+#if defined(__linux__)
 static inline int
 perf_event_open(struct perf_event_attr *attr,
 		pid_t pid,
@@ -50,6 +53,26 @@ perf_event_open(struct perf_event_attr *attr,
     attr->size = sizeof(*attr);
     return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);
 }
+#else
+#include <errno.h>
+
+struct perf_event_attr {
+	uint64_t config;
+	uint64_t type;
+	uint64_t sample_period;
+};
+
+static inline int
+perf_event_open(struct perf_event_attr *attr,
+		pid_t pid,
+		int cpu,
+		int group_fd,
+		unsigned long flags)
+{
+   errno = ENXIO;
+   return -1;
+}
+#endif
 
 uint64_t i915_type_id(void);
 int perf_i915_open(uint64_t config);
lib/igt_perf_null.c new file +45 -0

45 lines not on this page · raw message

lib/meson.build +10 -2
index 4a58d9cf..2cb944e2 100644
@@ -14,7 +14,6 @@ lib_sources = [
 	'igt_gt.c',
 	'igt_halffloat.c',
 	'igt_matrix.c',
-	'igt_perf.c',
 	'igt_primes.c',
 	'igt_rand.c',
 	'igt_rapl.c',
@@ -69,11 +68,13 @@ if host_machine.system() == 'linux'
 	lib_sources += [
 		'igt_aux.c',
 		'igt_kmod.c',
+		'igt_perf.c',
 	]
 else
 	lib_sources += [
 		'igt_aux_null.c',
 		'igt_kmod_null.c',
+		'igt_perf_null.c',
 	]
 endif
 
@@ -170,8 +171,15 @@ lin_igt_chipset_build = static_library('igt_chipset',
 lib_igt_chipset = declare_dependency(link_with : lin_igt_chipset_build,
                                      include_directories : inc)
 
+
+if host_machine.system() == 'linux'
+	igt_perf_sources = ['igt_perf.c']
+else
+	igt_perf_sources = ['igt_perf_null.c']
+endif
+
 lib_igt_perf_build = static_library('igt_perf',
-	['igt_perf.c'],
+	igt_perf_sources,
 	include_directories : inc)
 
 lib_igt_perf = declare_dependency(link_with : lib_igt_perf_build,
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#20 lore raw

PATCH 18/29 runner: Add support for non-Linux operating systems

In reply to D Scott Phillips

The runner depends on Linux specific functionality like signalfd and the watchdog interface. Provide stub functionality for other platforms so that the runner can continue with reduced functionality.

---
 runner/executor.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
runner/executor.c +27 -1
index f36bfd3d..095451c4 100644
@@ -1,7 +1,9 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <glib.h>
+#if defined(__linux__)
 #include <linux/watchdog.h>
+#endif
 #if HAVE_OPING
 #include <oping.h>
 #endif
@@ -13,7 +15,9 @@
 #include <sys/ioctl.h>
 #include <sys/select.h>
 #include <sys/poll.h>
+#if defined(__linux__)
 #include <sys/signalfd.h>
+#endif
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/types.h>
@@ -27,6 +31,12 @@
 #include "executor.h"
 #include "output_strings.h"
 
+#if !defined(__linux__)
+#define CLOCK_BOOTTIME CLOCK_REALTIME
+#define WDIOC_SETTIMEOUT 0
+#define WDIOC_KEEPALIVE 0
+#endif
+
 static struct {
 	int *fds;
 	size_t num_dogs;
@@ -674,7 +684,14 @@ static int monitor_output(pid_t child,
 	char *outbuf = NULL;
 	size_t outbufsize = 0;
 	char current_subtest[256] = {};
+#if defined(__linux__)
 	struct signalfd_siginfo siginfo;
+#else
+	struct signalfd_siginfo {
+		pid_t ssi_pid;
+		int ssi_signo;
+	} siginfo;
+#endif
 	ssize_t s;
 	int n, status;
 	int nfds = outfd;
@@ -1455,7 +1472,14 @@ static void oom_immortal(void)
 
 static bool should_die_because_signal(int sigfd)
 {
+#if defined(__linux__)
 	struct signalfd_siginfo siginfo;
+#else
+	struct signalfd_siginfo {
+		pid_t ssi_pid;
+		int ssi_signo;
+	} siginfo;
+#endif
 	int ret;
 	struct pollfd sigpoll = { .fd = sigfd, .events = POLLIN | POLLRDBAND };
 
@@ -1494,7 +1518,7 @@ bool execute(struct execute_state *state,
 	struct utsname unamebuf;
 	int resdirfd, testdirfd, unamefd, timefd;
 	sigset_t sigmask;
-	int sigfd;
+	int sigfd = -1;
 	double time_spent = 0.0;
 	bool status = true;
 
@@ -1543,7 +1567,9 @@ bool execute(struct execute_state *state,
 	sigaddset(&sigmask, SIGTERM);
 	sigaddset(&sigmask, SIGQUIT);
 	sigaddset(&sigmask, SIGHUP);
+#if defined(__linux__)
 	sigfd = signalfd(-1, &sigmask, O_CLOEXEC);
+#endif
 	sigprocmask(SIG_BLOCK, &sigmask, NULL);
 
 	if (sigfd < 0) {
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#21 lore raw

PATCH 19/29 Use ETIMEDOUT in place of ETIME on FreeBSD

In reply to D Scott Phillips

FreeBSD does not provide ETIME, and the drm interface is uniformly patched on that platform to use ETIMEDOUT in its place.

---
 lib/igt.h                        | 4 ++++
 lib/sw_sync.c                    | 1 +
 tests/i915/gem_ctx_persistence.c | 2 +-
 3 files changed, 6 insertions(+), 1 deletion(-)
lib/igt.h +4 -0
index a6c4e44d..18f55139 100644
@@ -56,4 +56,8 @@
 #include "i915/gem_mman.h"
 #include "i915/gem_engine_topology.h"
 
+#if defined(__FreeBSD__)
+#define ETIME ETIMEDOUT
+#endif
+
 #endif /* IGT_H */
lib/sw_sync.c +1 -0
index d671923c..6edcafcd 100644
@@ -35,6 +35,7 @@
 
 #include "sync_file.h"
 
+#include "igt.h"
 #include "igt_debugfs.h"
 #include "igt_kmod.h"
 #include "sw_sync.h"
tests/i915/gem_ctx_persistence.c +1 -1
index d68431ae..4c957f99 100644
@@ -28,7 +28,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#include "drmtest.h" /* gem_quiescent_gpu()! */
+#include "igt.h"
 #include "i915/gem_context.h"
 #include "i915/gem_engine_topology.h"
 #include "i915/gem_ring.h"
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#22 lore raw

PATCH 20/29 ilog2: Use libc provided fls() on FreeBSD

In reply to D Scott Phillips

FreeBSD's libc provides an fls() function with the same name and behavior, so simply omit our version on FreeBSD.

---
 benchmarks/ilog2.h | 2 ++
 1 file changed, 2 insertions(+)
benchmarks/ilog2.h +2 -0
index 596d7c23..c7d18094 100644
@@ -3,12 +3,14 @@
 
 #include <stdint.h>
 
+#if !defined(__FreeBSD__)
 static inline int fls(int x)
 {
         int r = -1;
         asm("bsrl %1,%0" : "=r" (r) : "rm" (x), "0" (-1));
         return r + 1;
 }
+#endif
 
 static inline int fls64(__u64 x)
 {
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#23 lore raw

PATCH 21/29 lib: undefine FreeBSD libc's ALIGN macro

In reply to D Scott Phillips

On FreeBSD, if you include many of the non-POSIX headers, you get inflicted with a definition of an ALIGN() macro that has something to do with network protocols. Here we include a header that provides it and then undefine it so that we can provide our own definition.

---
 lib/drmtest.h | 4 ++++
 1 file changed, 4 insertions(+)
lib/drmtest.h +4 -0
index 632c616b..0fc59311 100644
@@ -33,6 +33,10 @@
 #include <stdint.h>
 #include <sys/mman.h>
 #include <errno.h>
+#if defined(__FreeBSD__)
+# include <sys/param.h>
+# undef ALIGN
+#endif
 
 #include <xf86drm.h>
 
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#24 lore raw

PATCH 22/29 lib: Add FreeBSD-specific pthread logic

In reply to D Scott Phillips

Add a definition for FreeBSD's platform specific method of fetching a thread-id and delivering a signal to the current thread.

---
 lib/igt_aux.h               | 7 +++++++
 lib/igt_core.c              | 2 ++
 tests/i915/gem_close_race.c | 2 ++
 3 files changed, 11 insertions(+)
lib/igt_aux.h +7 -0
index 04d22904..5cbef592 100644
@@ -45,8 +45,15 @@
 # ifndef HAVE_GETTID
 #  define gettid() (pid_t)(syscall(__NR_gettid))
 # endif
+#else
+# ifndef HAVE_GETTID
+#  include <pthread_np.h>
+#  define gettid() (pid_t)(pthread_getthreadid_np())
+# endif
 #endif
+#if defined(__linux__)
 #define sigev_notify_thread_id _sigev_un._tid
+#endif
 
 /* auxialiary igt helpers from igt_aux.c */
 /* generally useful helpers */
lib/igt_core.c +2 -0
index 8df89905..c89030ba 100644
@@ -2398,6 +2398,8 @@ static void fatal_sig_handler(int sig)
 		pid_t tid = gettid();
 
 		syscall(SYS_tgkill, pid, tid, sig);
+#elif defined(__FreeBSD__)
+		pthread_kill(pthread_self(), sig);
 #else
 		pthread_t tid = pthread_self();
 		union sigval value = { .sival_ptr = NULL };
tests/i915/gem_close_race.c +2 -0
index 57e00480..cbef33e2 100644
@@ -51,7 +51,9 @@
 static uint32_t devid;
 static bool has_64bit_relocations;
 
+#if defined(__linux__)
 #define sigev_notify_thread_id _sigev_un._tid
+#endif
 
 static void selfcopy(int fd, uint32_t handle, int loops)
 {
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#25 lore raw

PATCH 23/29 lib/igt_kms: Add FreeBSD support

In reply to D Scott Phillips

Include the FreeBSD header that provides equivalent definitions to linux/kd.h, and omit igt_hotplug_watch which depends upon udev.

---
 lib/igt_kms.c | 9 +++++++++
 1 file changed, 9 insertions(+)
lib/igt_kms.c +9 -0
index d20daaad..790d1fe8 100644
@@ -41,6 +41,9 @@
 #elif HAVE_SYS_KD_H
 #include <sys/kd.h>
 #endif
+#if defined(__FreeBSD__)
+#include <sys/consio.h>
+#endif
 
 #include <libudev.h>
 #include <poll.h>
@@ -4117,6 +4120,7 @@ void igt_reset_connectors(void)
 		igt_sysfs_set(forced_connectors[i].dir, "status",  "detect");
 }
 
+#if defined(__linux__)
 /**
  * igt_watch_hotplug:
  *
@@ -4155,6 +4159,11 @@ struct udev_monitor *igt_watch_hotplug(void)
 
 	return mon;
 }
+#else
+struct udev_monitor *igt_watch_hotplug(void) {
+	return NULL;
+}
+#endif
 
 static bool event_detected(struct udev_monitor *mon, int timeout_secs,
 			   const char *property)
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#26 lore raw

PATCH 24/29 lib/ioctl_wrappers: Support FreeBSD in igt_require_gem

In reply to D Scott Phillips

On FreeBSD, fdescfs is mounted at /dev/fd/ and provides equivalent functionality to Linux's /proc/self/fd.

---
 lib/ioctl_wrappers.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
lib/ioctl_wrappers.c +5 -1
index 78b92bd2..3b060f56 100644
@@ -1222,7 +1222,7 @@ static void reset_device(int fd)
 
 void igt_require_gem(int fd)
 {
-	char path[256];
+	char path[256] = {0};
 	int err;
 
 	igt_require_intel(fd);
@@ -1232,7 +1232,11 @@ void igt_require_gem(int fd)
 	 * of a wedged device, not for actually waiting on outstanding
 	 * requests! So create a new drm_file for the device that is clean.
 	 */
+#if defined(__linux__)
 	snprintf(path, sizeof(path), "/proc/self/fd/%d", fd);
+#elif defined(__FreeBSD__)
+	snprintf(path, sizeof(path), "/dev/fd/%d", fd);
+#endif
 	fd = open(path, O_RDWR);
 	igt_assert_lte(0, fd);
 
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#27 lore raw

PATCH 25/29 lib/intel_os: Implement get_avail_ram and get_total_swap for FreeBSD

In reply to D Scott Phillips

FreeBSD provides these values through sysctl.

---
 lib/intel_os.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
lib/intel_os.c +16 -0
index 8458d39a..d476e9bc 100644
@@ -44,6 +44,8 @@
 #include <sys/sysinfo.h>
 #elif defined(HAVE_SWAPCTL) /* Solaris */
 #include <sys/swap.h>
+#elif defined(__FreeBSD__)
+#include <sys/sysctl.h>
 #endif
 #include <sys/resource.h>
 
@@ -148,6 +150,14 @@ intel_get_avail_ram_mb(void)
         npages = sysconf(_SC_AVPHYS_PAGES);
 
 	retval = (uint64_t) pagesize * npages;
+#elif defined(__FreeBSD__)
+	int hw_physmem[] = {CTL_HW, HW_PHYSMEM};
+	size_t size = sizeof(retval);
+	int ret;
+	ret = sysctl(hw_physmem, ARRAY_SIZE(hw_physmem), &retval, &size, NULL,
+		     0);
+	if (ret != 0 || size != sizeof(retval))
+		retval = 0;
 #else
 #error "Unknown how to get available RAM for this OS"
 #endif
@@ -210,6 +220,12 @@ intel_get_total_swap_mb(void)
 	free(buf);
 
 	retval = (uint64_t) pagesize * totalpages;
+#elif defined(__FreeBSD__)
+	size_t size = sizeof(retval);
+	int ret;
+	ret = sysctlbyname("vm.swap_total", &retval, &size, NULL, 0);
+	if (ret != 0 || size != sizeof(retval))
+		retval = 0;
 #else
 #warning "Unknown how to get swap size for this OS"
 	return 0;
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#28 lore raw

PATCH 26/29 lib/igt_device: Implement get_card_index for FreeBSD

In reply to D Scott Phillips

On FreeBSD, the device nodes for drm devices do not have an st_rdev value that corresponds to the drm card index. Instead we can use libutil to look up our open file descriptors through the sysctl interface.

---
 lib/igt_device.c | 20 ++++++++++++++++++++
 lib/meson.build  |  1 +
 meson.build      |  6 ++++++
 3 files changed, 27 insertions(+)
lib/igt_device.c +20 -0
index 01a9eff4..327c9c63 100644
@@ -27,6 +27,10 @@
 #include <sys/stat.h>
 #if defined(__linux__)
 #include <sys/sysmacros.h>
+#elif defined(__FreeBSD__)
+#include <sys/user.h>
+#include <libgen.h>
+#include <libutil.h>
 #endif
 #include "igt.h"
 #include "igt_device.h"
@@ -111,11 +115,27 @@ void igt_device_drop_master(int fd)
  */
 int igt_device_get_card_index(int fd)
 {
+#if defined(__linux__)
 	struct stat st;
 
 	igt_fail_on(fstat(fd, &st) || !S_ISCHR(st.st_mode));
 
 	return minor(st.st_rdev);
+#elif defined(__FreeBSD__)
+	struct kinfo_file *files, *f;
+	int nfiles, idx = 0;
+
+	files = kinfo_getfile(getpid(), &nfiles);
+	for (f = files; f < files + nfiles; f++) {
+		if (f->kf_fd == fd) {
+			idx = atoi(basename(f->kf_path));
+			break;
+		}
+	}
+	free(files);
+
+	return idx;
+#endif
 }
 
 #define IGT_DEV_PATH_LEN 80
lib/meson.build +1 -0
index 2cb944e2..710b89b5 100644
@@ -86,6 +86,7 @@ lib_deps = [
 	libkmod,
 	libprocps,
 	libudev,
+	libutil,
 	math,
 	pciaccess,
 	pixman,
meson.build +6 -0
index 4d5003ba..ffe9ae1f 100644
@@ -93,6 +93,12 @@ config = configuration_data()
 
 null_dep = dependency('', required : false)
 
+if host_machine.system() == 'freebsd'
+	libutil = cc.find_library('libutil')
+else
+	libutil = null_dep
+endif
+
 libdrm_info = []
 libdrm_intel = null_dep
 libdrm_nouveau = null_dep
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#29 lore raw

PATCH 27/29 lib/igt_debugfs: Implement mount() for FreeBSD

In reply to D Scott Phillips

debugfs is typically mounted at a different path on FreeBSD, and the mount function prototype is slightly different.

---
 lib/igt_debugfs.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
lib/igt_debugfs.c +12 -0
index 5a9c8c3c..33592df3 100644
@@ -116,6 +116,7 @@ static bool is_mountpoint(const char *path)
 
 static const char *__igt_debugfs_mount(void)
 {
+#if defined(__linux__)
 	if (is_mountpoint("/sys/kernel/debug"))
 		return "/sys/kernel/debug";
 
@@ -126,6 +127,17 @@ static const char *__igt_debugfs_mount(void)
 		return NULL;
 
 	return "/sys/kernel/debug";
+#elif defined(__FreeBSD__)
+	if (is_mountpoint("/compat/linux/debug"))
+		return "/compat/linux/debug";
+
+	if (mount("lindebugfs", "/compat/linux/debug", 0, NULL))
+		return NULL;
+
+	return "/compat/linux/debug";
+#else
+#error Do not know how to mount debugfs
+#endif
 }
 
 /**
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#30 lore raw

PATCH 28/29 build: Add support for building on non-Linux

In reply to D Scott Phillips

This makes libkmod and libprocps dependencies option on non-Linux platforms and skips building tests which depend on Linux-specific functionality.

---
 benchmarks/meson.build |  7 ++++++-
 meson.build            |  4 ++--
 tests/meson.build      | 30 ++++++++++++++++++++----------
 tools/meson.build      | 12 +++++++-----
 4 files changed, 35 insertions(+), 18 deletions(-)
benchmarks/meson.build +6 -1
index 397f3b8d..d6e05697 100644
@@ -11,12 +11,17 @@ benchmark_progs = [
 	'gem_mmap',
 	'gem_prw',
 	'gem_set_domain',
-	'gem_syslatency',
 	'kms_vblank',
 	'prime_lookup',
 	'vgem_mmap',
 ]
 
+if host_machine.system() == 'linux'
+	benchmark_progs += [
+		'gem_syslatency',
+	]
+endif
+
 if libdrm_intel.found()
 	benchmark_progs += [
 		'intel_upload_blit_large',
meson.build +2 -2
index ffe9ae1f..409f35f5 100644
@@ -122,8 +122,8 @@ endif
 build_info += 'With libdrm: ' + ','.join(libdrm_info)
 
 pciaccess = dependency('pciaccess', version : '>=0.10')
-libkmod = dependency('libkmod')
-libprocps = dependency('libprocps', required : true)
+libkmod = dependency('libkmod', required : host_machine.system() == 'linux')
+libprocps = dependency('libprocps', required : host_machine.system() == 'linux')
 
 libunwind = dependency('libunwind', required : get_option('libunwind'))
 build_info += 'With libunwind: @0@'.format(libunwind.found())
tests/meson.build +20 -10
index d931cc37..35b75484 100644
@@ -9,7 +9,6 @@ test_progs = [
 	'drm_import_export',
 	'drm_mm',
 	'drm_read',
-	'fbdev',
 	'kms_3d',
 	'kms_addfb_basic',
 	'kms_atomic',
@@ -21,11 +20,9 @@ test_progs = [
 	'kms_ccs',
 	'kms_color',
 	'kms_concurrent',
-	'kms_content_protection',
 	'kms_crtc_background_color',
 	'kms_cursor_crc',
 	'kms_cursor_edge_walk',
-	'kms_cursor_legacy',
 	'kms_dp_aux_dev',
 	'kms_dp_dsc',
 	'kms_dp_tiled_display',
@@ -56,7 +53,6 @@ test_progs = [
 	'kms_prop_blob',
 	'kms_properties',
 	'kms_psr',
-	'kms_psr2_su',
 	'kms_pwrite_crc',
 	'kms_rmfb',
 	'kms_rotation_crc',
@@ -84,7 +80,6 @@ test_progs = [
 	'syncobj_basic',
 	'syncobj_wait',
 	'template',
-	'tools_test',
 	'v3d_get_bo_offset',
 	'v3d_get_param',
 	'v3d_mmap',
@@ -100,6 +95,16 @@ test_progs = [
 	'vgem_slow',
 ]
 
+if host_machine.system() == 'linux'
+	test_progs += [
+		'fbdev',
+		'kms_content_protection',
+		'kms_cursor_legacy',
+		'kms_psr2_su',
+		'tools_test',
+	]
+endif
+
 i915_progs = [
 	'gen3_mixed_blits',
 	'gen3_render_linear_blits',
@@ -151,7 +156,6 @@ i915_progs = [
 	'gem_exec_parse_blt',
 	'gem_exec_reloc',
 	'gem_exec_reuse',
-	'gem_exec_schedule',
 	'gem_exec_store',
 	'gem_exec_suspend',
 	'gem_exec_whisper',
@@ -172,7 +176,6 @@ i915_progs = [
 	'gem_media_fill',
 	'gem_media_vme',
 	'gem_mmap',
-	'gem_mmap_gtt',
 	'gem_mmap_offset_exhaustion',
 	'gem_mmap_wc',
 	'gem_partial_pwrite_pread',
@@ -221,7 +224,6 @@ i915_progs = [
 	'gem_tiling_max_stride',
 	'gem_unfence_active_buffers',
 	'gem_unref_active_buffers',
-	'gem_userptr_blits',
 	'gem_vm_create',
 	'gem_wait',
 	'gem_workarounds',
@@ -229,11 +231,9 @@ i915_progs = [
 	'i915_fb_tiling',
 	'i915_getparams_basic',
 	'i915_hangman',
-	'i915_module_load',
 	'i915_pm_backlight',
 	'i915_pm_lpsp',
 	'i915_pm_rc6_residency',
-	'i915_pm_rpm',
 	'i915_pm_dc',
 	'i915_pm_rps',
 	'i915_pm_sseu',
@@ -242,6 +242,16 @@ i915_progs = [
 	'i915_suspend',
 ]
 
+if host_machine.system() == 'linux'
+	i915_progs += [
+		'gem_exec_schedule',
+		'gem_mmap_gtt',
+		'gem_userptr_blits',
+		'i915_module_load',
+		'i915_pm_rpm',
+	]
+endif
+
 test_deps = [ igt_deps ]
 
 if libdrm_nouveau.found()
tools/meson.build +7 -5
index 74822a33..25233478 100644
@@ -90,11 +90,13 @@ install_subdir('registers', install_dir : datadir,
 		 'Makefile', 'Makefile.in', 'Makefile.am',
 	       ])
 
-shared_library('intel_aubdump', 'aubdump.c',
-	       dependencies : [ lib_igt_chipset, dlsym ],
-	       name_prefix : '',
-	       install : true,
-	       soversion : '0')
+if host_machine.system() == 'linux'
+	shared_library('intel_aubdump', 'aubdump.c',
+		       dependencies : [ lib_igt_chipset, dlsym ],
+		       name_prefix : '',
+		       install : true,
+		       soversion : '0')
+endif
 
 executable('intel_gpu_top', 'intel_gpu_top.c',
 	   install : true,
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#31 lore raw

PATCH 29/29 lib/igt_device_scan: add null implementation

In reply to D Scott Phillips
---
 lib/igt_device_scan_null.c | 67 ++++++++++++++++++++++++++++++++++++++
 lib/meson.build            |  3 +-
 2 files changed, 69 insertions(+), 1 deletion(-)
 create mode 100644 lib/igt_device_scan_null.c
lib/igt_device_scan_null.c new file +67 -0
new file mode 100644
index 00000000..27f2d94b
@@ -0,0 +1,67 @@
+/*
+ * Copyright © 2019 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#include <fcntl.h>
+#include "igt_device_scan.h"
+
+void igt_devices_scan(bool force) {
+}
+
+void igt_devices_print(enum igt_devices_print_type printtype) {
+}
+
+void igt_devices_print_vendors(void) {
+}
+
+void igt_device_print_filter_types(void) {
+}
+
+bool igt_device_is_filter_set(void) {
+	return false;
+}
+
+void igt_device_filter_set(const char *filter) {
+}
+
+void igt_device_filter_free(void) {
+}
+
+const char *igt_device_filter_get(void) {
+	return NULL;
+}
+
+bool igt_device_card_match(const char *filter, struct igt_device_card *card) {
+	card->subsystem[0] = '\0';
+	strcpy(card->card, "/dev/dri/card0");
+	strcpy(card->render, "/dev/dri/renderD128");
+	return true;
+}
+
+int igt_open_card(struct igt_device_card *card) {
+	return open(card->card, O_RDWR);
+}
+
+int igt_open_render(struct igt_device_card *card) {
+	return open(card->render, O_RDWR);
+}
lib/meson.build +2 -1
index 710b89b5..8bf02653 100644
@@ -10,7 +10,6 @@ lib_sources = [
 	'igt_color_encoding.c',
 	'igt_debugfs.c',
 	'igt_device.c',
-	'igt_device_scan.c',
 	'igt_gt.c',
 	'igt_halffloat.c',
 	'igt_matrix.c',
@@ -67,12 +66,14 @@ lib_sources = [
 if host_machine.system() == 'linux'
 	lib_sources += [
 		'igt_aux.c',
+		'igt_device_scan.c',
 		'igt_kmod.c',
 		'igt_perf.c',
 	]
 else
 	lib_sources += [
 		'igt_aux_null.c',
+		'igt_device_scan_null.c',
 		'igt_kmod_null.c',
 		'igt_perf_null.c',
 	]
Signature · 6 lines
2.23.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#32 lore raw

[igt-dev] ✗ GitLab.Pipeline: warning for Add FreeBSD Support

In reply to D Scott Phillips
== Series Details ==

== Series Details ==

Series: Add FreeBSD Support
URL : https://patchwork.freedesktop.org/series/70729/
State : warning

== Summary ==

Did not get list of undocumented tests for this run, something is wrong!

Other than that, pipeline status: FAILED.

see https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/pipelines/87430 for the overview.

test:ninja-test has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/1113838):

5/292 lib: igt_describe FAIL 0.07 s (killed by signal 6 SIGABRT)

--- command ---
/builds/gfx-ci/igt-ci-tags/build/lib/tests/igt_describe
--- stderr ---
igt_describe: ../lib/tests/igt_describe.c:248: main: Assertion `0 == strcmp(DESCRIBE_ALL_OUTPUT, out)' failed.
-------

Full log written to /builds/gfx-ci/igt-ci-tags/build/meson-logs/testlog.txt
FAILED: meson-test
/usr/bin/meson test --no-rebuild --print-errorlogs
ninja: build stopped: subcommand failed. section_end:1576027580:build_script section_start:1576027580:after_script section_end:1576027582:after_script section_start:1576027582:upload_artifacts_on_failure section_end:1576027583:upload_artifacts_on_failure ERROR: Job failed: exit code 1


test:ninja-test-clang has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/1113839):

5/292 lib: igt_describe FAIL 0.12 s (killed by signal 6 SIGABRT)

--- command ---
/builds/gfx-ci/igt-ci-tags/build/lib/tests/igt_describe
--- stderr ---
igt_describe: ../lib/tests/igt_describe.c:248: int main(int, char **): Assertion `0 == strcmp(DESCRIBE_ALL_OUTPUT, out)' failed.
-------

Full log written to /builds/gfx-ci/igt-ci-tags/build/meson-logs/testlog.txt
FAILED: meson-test
/usr/bin/meson test --no-rebuild --print-errorlogs
ninja: build stopped: subcommand failed. section_end:1576027708:build_script section_start:1576027708:after_script section_end:1576027712:after_script section_start:1576027712:upload_artifacts_on_failure section_end:1576027717:upload_artifacts_on_failure ERROR: Job failed: exit code 1


test:ninja-test-minimal has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/1113840):

5/20 lib: igt_describe FAIL 0.05 s (killed by signal 6 SIGABRT)

--- command ---
/builds/gfx-ci/igt-ci-tags/build/lib/tests/igt_describe
--- stderr ---
igt_describe: ../lib/tests/igt_describe.c:248: main: Assertion `0 == strcmp(DESCRIBE_ALL_OUTPUT, out)' failed.
-------

Full log written to /builds/gfx-ci/igt-ci-tags/build/meson-logs/testlog.txt
FAILED: meson-test
/usr/bin/meson test --no-rebuild --print-errorlogs
ninja: build stopped: subcommand failed. section_end:1576027591:build_script section_start:1576027591:after_script section_end:1576027593:after_script section_start:1576027593:upload_artifacts_on_failure section_end:1576027594:upload_artifacts_on_failure ERROR: Job failed: exit code 1


test:ninja-test-arm64 has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/1113841):

  (runner_test:2781) igt_core-INFO:   #3 ../runner/runner_tests.c:207 main()
  (runner_test:2781) igt_core-INFO:   #4 [__libc_start_main+0xe4]
  (runner_test:2781) igt_core-INFO:   #5 [_start+0x34]

**** END ****
-------

Full log written to /builds/gfx-ci/igt-ci-tags/build/meson-logs/testlog.txt
FAILED: meson-test
/usr/bin/meson test --no-rebuild --print-errorlogs
ninja: build stopped: subcommand failed. section_end:1576027619:build_script section_start:1576027619:after_script section_end:1576027622:after_script section_start:1576027622:upload_artifacts_on_failure Uploading artifacts...
build: found 1367 matching files 
Uploading artifacts to coordinator... ok  id=1113841 responseStatus=201 Created token=yisbfGa-
section_end:1576027638:upload_artifacts_on_failure ERROR: Job failed: exit code 1


test:ninja-test-armhf has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/1113842):

  (runner_test:6370) igt_core-INFO:   #3 ../runner/runner_tests.c:207 main()
  (runner_test:6370) igt_core-INFO:   #4 [__libc_start_main+0x98]
  (runner_test:6370) igt_core-INFO:   #5 [_start+0x34]

**** END ****
-------

Full log written to /builds/gfx-ci/igt-ci-tags/build/meson-logs/testlog.txt
FAILED: meson-test
/usr/bin/meson test --no-rebuild --print-errorlogs
ninja: build stopped: subcommand failed. section_end:1576027636:build_script section_start:1576027636:after_script section_end:1576027638:after_script section_start:1576027638:upload_artifacts_on_failure Uploading artifacts...
build: found 1368 matching files 
Uploading artifacts to coordinator... ok  id=1113842 responseStatus=201 Created token=8JmvzRer
section_end:1576027648:upload_artifacts_on_failure ERROR: Job failed: exit code 1


test:ninja-test-mips has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/1113843):
skip-two
exit:77 ('
(runner_test:3066) igt_core-INFO: Stack trace:
**** END ****
-------

Full log written to /builds/gfx-ci/igt-ci-tags/build/meson-logs/testlog.txt
FAILED: meson-test
/usr/bin/meson test --no-rebuild --print-errorlogs
ninja: build stopped: subcommand failed. section_end:1576027650:build_script section_start:1576027650:after_script section_end:1576027652:after_script section_start:1576027652:upload_artifacts_on_failure Uploading artifacts...
build: found 1367 matching files 
Uploading artifacts to coordinator... ok  id=1113843 responseStatus=201 Created token=Wzx6Tkmi
section_end:1576027661:upload_artifacts_on_failure ERROR: Job failed: exit code 1


test:test-list-diff has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/1113844):
Downloading artifacts from coordinator... ok  id=1113837 responseStatus=200 OK token=fm6a3z1R
Downloading artifacts for build:tests-debian-meson (1113832)...
Downloading artifacts from coordinator... ok  id=1113832 responseStatus=200 OK token=dtUDS1AD
section_end:1576027637:download_artifacts
section_start:1576027637:build_script
Authenticating with credentials from job payload (GitLab Registry)
$ diff <(sed "s/ /\n/g" meson-test-list.txt| grep -v 'vc4\|v3d\|panfrost' | sort) <(sed "s/ /\n/g" autotools-test-list.txt | sort) 1d0
<
10c9
< amdgpu/amd_prime-e
---

Quoted 1 line

amdgpu/amd_prime

section_end:1576027639:build_script section_start:1576027639:after_script section_end:1576027640:after_script section_start:1576027640:upload_artifacts_on_failure section_end:1576027642:upload_artifacts_on_failure ERROR: Job failed: exit code 1


== Logs ==

For more details see: https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/pipelines/87430
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#33 lore raw
In reply to D Scott Phillips
Quoted 14 lines · D Scott Phillips

FreeBSD maintains a port of drm and a few drivers: amdgpu, i915, radeon, vboxvideo, vmwgfx:

https://github.com/FreeBSDDesktop/kms-drm/

Recently I backported some drm & i915 security patches into our tree and was lacking a way to verify the backports. Here is my attempt at adding FreeBSD support to igt.

I've tried to order the series so that what I believe will be less controversial comes nearer the start. I've also tried to err on the side of too many small patches, so I'm happy to squash things where that seems more appropriate to people.

Quoted 4 lines

The "null" implementations toward the end are probably more like RFC ideas. I'm willing to take other approaches there if anyone has a better idea for how to handle large sections of code that are more linux specific. Cheers,

I'll mostly defer to Petri and Arek, the IGT maintainers, on the details.

I think the bigger questions are, 1) How do we ensure this does not bitrot in a matter of weeks? Which translates to, 2) Who is going to automate and maintain continuous build testing? And, 3) Who's going to take ownership of the port in general?

Personally, I don't think this is going to work long term just by merging the port upstream. I think without the continuous support from people who care about FreeBSD, this is going to be a net negative.

BR,
Jani.

Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#34 lore raw
Quoted 11 lines · Jani Nikula

I'll mostly defer to Petri and Arek, the IGT maintainers, on the details.

I think the bigger questions are, 1) How do we ensure this does not bitrot in a matter of weeks? Which translates to, 2) Who is going to automate and maintain continuous build testing? And, 3) Who's going to take ownership of the port in general?

Personally, I don't think this is going to work long term just by merging the port upstream. I think without the continuous support from people who care about FreeBSD, this is going to be a net negative.

Right, I think that's a fair point. What level of continuous support do you think would get us out of the negative here? A continuous build could be fairly easy to get configured, but might be a side workflow apart from how normal CI results are presented. I think that could be a reasonable indication that things aren't rotting. More sophisticated CI is within the realm of possibility but could be quite a bit harder to get off the ground with.

Ultimately, I think as long as the kernel driver port exists this is something that we will want.

As to who owns the port, FreeBSD has a "Graphics Team" that collectively owns the kernel driver port, so I think the most robust answer going forward is to have them own this port. I can take this up with them and see if they'll affirm that they will take some ownership here.
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#35 lore raw
Quoted 14 lines · D Scott Phillips
Quoted 11 lines · Jani Nikula

I'll mostly defer to Petri and Arek, the IGT maintainers, on the details.

I think the bigger questions are, 1) How do we ensure this does not bitrot in a matter of weeks? Which translates to, 2) Who is going to automate and maintain continuous build testing? And, 3) Who's going to take ownership of the port in general?

Personally, I don't think this is going to work long term just by merging the port upstream. I think without the continuous support from people who care about FreeBSD, this is going to be a net negative.

Quoted 7 lines

Right, I think that's a fair point. What level of continuous support do you think would get us out of the negative here? A continuous build could be fairly easy to get configured, but might be a side workflow apart from how normal CI results are presented. I think that could be a reasonable indication that things aren't rotting. More sophisticated CI is within the realm of possibility but could be quite a bit harder to get off the ground with.

I'd say the bar to reach is

* build-testing for each commit
* someone responsible for fixing issues in the above in a timely manner

Build-testing we can reach quite easily in gitlab, for some values of easily, but the second point is harder.

Quoted 2 lines

Ultimately, I think as long as the kernel driver port exists this is something that we will want.

Yep. Ultimately, running the tests on HW on FreeBSD is a change that I would very much welcome.

Quoted 4 lines

As to who owns the port, FreeBSD has a "Graphics Team" that collectively owns the kernel driver port, so I think the most robust answer going forward is to have them own this port. I can take this up with them and see if they'll affirm that they will take some ownership here.

Thanks for doing this!

As for the series as such:

There's some trivial cleanups in there that I suspect will help even Linux users on non-glibc systems that we can merge as is. I'm going to go through reviewing the series later this week for those parts.

The null-implementation patches are for sure getting a NAK in that form. They need a function-by-function analysis of whether the correct "do nothing" approach is actually doing nothing or straight up igt_skip("Not supported on this platform"); in some form. For example, tests that use igt_fork_signal_helper will test nothing if they don't manage to fork a periodical interrupter process.

Signature · 5 lines
Petri Latvala
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#36 lore raw
Quoted 23 lines · Petri Latvala
Quoted 14 lines · D Scott Phillips
Quoted 11 lines · Jani Nikula

I'll mostly defer to Petri and Arek, the IGT maintainers, on the details.

I think the bigger questions are, 1) How do we ensure this does not bitrot in a matter of weeks? Which translates to, 2) Who is going to automate and maintain continuous build testing? And, 3) Who's going to take ownership of the port in general?

Personally, I don't think this is going to work long term just by merging the port upstream. I think without the continuous support from people who care about FreeBSD, this is going to be a net negative.

Quoted 7 lines

Right, I think that's a fair point. What level of continuous support do you think would get us out of the negative here? A continuous build could be fairly easy to get configured, but might be a side workflow apart from how normal CI results are presented. I think that could be a reasonable indication that things aren't rotting. More sophisticated CI is within the realm of possibility but could be quite a bit harder to get off the ground with.

Quoted 7 lines

I'd say the bar to reach is

* build-testing for each commit
* someone responsible for fixing issues in the above in a timely manner

Build-testing we can reach quite easily in gitlab, for some values of easily, but the second point is harder.

Do we have any FreeBSD runners[0] available on freedesktop's GitLab already? Or do you have something else (virt) in mind?

[0]: https://docs.gitlab.com/runner/install/freebsd.html

Quoted 12 lines
Quoted 3 lines

Ultimately, I think as long as the kernel driver port exists this is something that we will want.

Yep. Ultimately, running the tests on HW on FreeBSD is a change that I would very much welcome.

Quoted 4 lines

As to who owns the port, FreeBSD has a "Graphics Team" that collectively owns the kernel driver port, so I think the most robust answer going forward is to have them own this port. I can take this up with them and see if they'll affirm that they will take some ownership here.

Quoted 7 lines

Thanks for doing this!

As for the series as such:

There's some trivial cleanups in there that I suspect will help even Linux users on non-glibc systems that we can merge as is. I'm going to go through reviewing the series later this week for those parts.

Google is maintaining IGT for Android port and they decided it's easier to do that out of tree. FreeBSD is closer to what most IGT devs are using, so it shouldn't be too much pain for both FreeBSD and Linux folks.

Anyway, since Android is also a non-glibc system I think it's worth looking at what they have been cooking on their side:

https://android.googlesource.com/platform/external/igt-gpu-tools/+log

Signature · 2 lines
Cheers,
Arek
Quoted 10 lines

The null-implementation patches are for sure getting a NAK in that form. They need a function-by-function analysis of whether the correct "do nothing" approach is actually doing nothing or straight up igt_skip("Not supported on this platform"); in some form. For example, tests that use igt_fork_signal_helper will test nothing if they don't manage to fork a periodical interrupter process.

Signature · 1 line
Petri Latvala

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev