* [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility
@ 2022-10-06 2:23 Jake Freeland
2022-10-06 3:24 ` [igt-dev] ✓ Fi.CI.BAT: success for Introduced partial FreeBSD compatibility (rev8) Patchwork
` (3 more replies)
0 siblings, 4 replies; 20+ messages in thread
From: Jake Freeland @ 2022-10-06 2:23 UTC (permalink / raw)
To: igt-dev; +Cc: Jake Freeland
FreeBSD's Linux compatbility layer, LinuxKPI, has introduced
modern drm drivers to the FreeBSD desktop. With drm drivers,
comes the need for drm testing. This patch allows a portion
of igt-gpu-tools to compile on FreeBSD
Signed-off-by: Jake Freeland <jfree@freebsd.org>
---
benchmarks/gem_exec_tracer.c | 4 ++
benchmarks/gem_syslatency.c | 6 ++
include/linux-uapi/sync_file.h | 5 ++
lib/i915/intel_memory_region.c | 4 ++
lib/i915/perf.c | 2 +
lib/igt_audio.c | 4 ++
lib/igt_aux.c | 2 +
lib/igt_aux.h | 6 +-
lib/igt_core.c | 11 ++-
lib/igt_core.h | 8 +++
lib/igt_debugfs.c | 2 +
lib/igt_device.c | 2 +
lib/igt_device_scan.c | 4 ++
lib/igt_eld.c | 4 ++
lib/igt_frame.c | 4 ++
lib/igt_freebsd.h | 123 +++++++++++++++++++++++++++++++++
lib/igt_kmod.h | 2 +
lib/igt_kms.c | 4 ++
lib/igt_os.c | 19 +++++
lib/igt_perf.c | 2 +
lib/igt_perf.h | 4 ++
lib/igt_pm.c | 2 +
lib/igt_sysfs.c | 2 +
lib/tests/igt_exit_handler.c | 4 ++
lib/tests/igt_fork.c | 2 +-
lib/tests/igt_tests_common.h | 9 +++
runner/executor.c | 6 ++
runner/job_list.c | 5 ++
tests/i915/gem_close_race.c | 2 +
tests/i915/gem_mmap_gtt.c | 2 +-
tests/i915/gem_mmap_offset.c | 2 +-
tests/i915/i915_module_load.c | 2 +
tests/i915/i915_pm_backlight.c | 4 ++
tests/i915/i915_pm_rpm.c | 8 +++
tests/kms_content_protection.c | 2 +
tests/kms_flip.c | 4 ++
tests/kms_sysfs_edid_timing.c | 4 ++
tests/tools_test.c | 4 ++
tools/intel_gvtg_test.c | 4 ++
39 files changed, 280 insertions(+), 10 deletions(-)
create mode 100644 lib/igt_freebsd.h
diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
index e6973991..7e86473e 100644
--- a/benchmarks/gem_exec_tracer.c
+++ b/benchmarks/gem_exec_tracer.c
@@ -41,6 +41,10 @@
#include "intel_aub.h"
#include "intel_chipset.h"
+#ifdef __FreeBSD__
+#include "igt_freebsd.h"
+#endif
+
static int (*libc_close)(int fd);
static int (*libc_ioctl)(int fd, unsigned long request, void *argp);
diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
index 035ee934..dafc6ac0 100644
--- a/benchmarks/gem_syslatency.c
+++ b/benchmarks/gem_syslatency.c
@@ -42,12 +42,18 @@
#include <limits.h>
#include "drm.h"
+#ifdef __linux__
#include <linux/unistd.h>
+#elif defined(__FreeBSD__)
+#include "igt_freebsd.h"
+#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/include/linux-uapi/sync_file.h b/include/linux-uapi/sync_file.h
index b4f2db00..270c1cbc 100644
--- a/include/linux-uapi/sync_file.h
+++ b/include/linux-uapi/sync_file.h
@@ -12,8 +12,13 @@
#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 "igt_freebsd.h"
+#endif
/**
* struct sync_merge_data - data passed to merge ioctl
diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
index 568bace9..0a59f290 100644
--- a/lib/i915/intel_memory_region.c
+++ b/lib/i915/intel_memory_region.c
@@ -21,7 +21,11 @@
* IN THE SOFTWARE.
*/
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <limits.h>
+#endif
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/time.h>
diff --git a/lib/i915/perf.c b/lib/i915/perf.c
index d88835ff..beda6b8a 100644
--- a/lib/i915/perf.c
+++ b/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/lib/igt_audio.c b/lib/igt_audio.c
index e0b1bafe..201a39c6 100644
--- a/lib/igt_audio.c
+++ b/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/lib/igt_aux.c b/lib/igt_aux.c
index edb53425..d7e2714f 100644
--- a/lib/igt_aux.c
+++ b/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"
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index c8d487b6..912f36c1 100644
--- a/lib/igt_aux.h
+++ b/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/lib/igt_core.c b/lib/igt_core.c
index e7425326..b4b8877f 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -43,9 +43,7 @@
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
-#ifdef __linux__
#include <sys/syscall.h>
-#endif
#include <pthread.h>
#include <sys/utsname.h>
#include <termios.h>
@@ -786,6 +784,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
static void oom_adjust_for_doom(void)
{
+#ifdef __linux__
int fd;
const char always_kill[] = "1000";
@@ -793,7 +792,13 @@ 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);
-
+#elif defined(__FreeBSD__)
+ /*
+ * oom_score_adj not present in FreeBSD's linprocfs.
+ * Stop process directly instead.
+ */
+ raise(SIGTERM);
+#endif
}
/**
diff --git a/lib/igt_core.h b/lib/igt_core.h
index aa98e8ed..cc382497 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -31,7 +31,11 @@
#define IGT_CORE_H
#include <assert.h>
+#ifdef __linux__
#include <byteswap.h>
+#elif defined(__FreeBSD__)
+#include <sys/endian.h>
+#endif
#include <setjmp.h>
#include <stdbool.h>
#include <stdint.h>
@@ -43,6 +47,10 @@
#include <getopt.h>
#include <unistd.h>
+#ifdef __FreeBSD__
+#include "igt_freebsd.h"
+#endif
+
#ifndef IGT_LOG_DOMAIN
#define IGT_LOG_DOMAIN (NULL)
#endif
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index a56688a5..fa1e3b69 100644
--- a/lib/igt_debugfs.c
+++ b/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>
diff --git a/lib/igt_device.c b/lib/igt_device.c
index fddfba72..49b77122 100644
--- a/lib/igt_device.c
+++ b/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/lib/igt_device_scan.c b/lib/igt_device_scan.c
index eb6b45b8..6a921d52 100644
--- a/lib/igt_device_scan.c
+++ b/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/lib/igt_eld.c b/lib/igt_eld.c
index ef6625df..e05ad6de 100644
--- a/lib/igt_eld.c
+++ b/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/lib/igt_frame.c b/lib/igt_frame.c
index 45523a79..ab74e678 100644
--- a/lib/igt_frame.c
+++ b/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/lib/igt_freebsd.h b/lib/igt_freebsd.h
new file mode 100644
index 00000000..de349148
--- /dev/null
+++ b/lib/igt_freebsd.h
@@ -0,0 +1,123 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (c) 2022, Jake Freeland <jfree@FreeBSD.org>
+ *
+ * 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.
+ */
+
+#if !defined(IGT_FREEBSD_H) && defined(__FreeBSD__)
+#define IGT_FREEBSD_H
+
+#include <sys/errno.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/sched.h>
+#include <sys/types.h>
+#include <sys/watchdog.h>
+
+#include <pthread.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <unistd.h>
+
+/*
+ * Proper substitutions:
+ * The following macros replace Linux-specific functions
+ * and macros with their FreeBSD equivalents.
+ */
+
+#define __s32 int32_t
+#define __u32 uint32_t
+#define __u64 uint64_t
+
+#define sighandler_t sig_t
+#define ino64_t ino_t
+
+#define jmp_buf sigjmp_buf
+
+#define PTRACE_TRACEME PT_TRACE_ME
+#define PTRACE_ATTACH PT_ATTACH
+#define PTRACE_PEEKDATA PT_READ_D
+#define PTRACE_POKEDATA PT_WRITE_D
+#define PTRACE_DETACH PT_DETACH
+
+#define I2C_RDWR I2CRDWR
+#define I2C_M_RD IIC_M_RD
+#define i2c_msg iic_msg
+#define i2c_rdwr_ioctl_data iic_rdwr_data
+
+#define bswap_32(x) bswap32(x)
+
+#define _IOC_TYPE(nr) (((nr) >> 8) & 255)
+
+#define SYS_getdents64 SYS_freebsd11_getdents
+
+#define mount(src, dest, fstype, flags, data) \
+ mount(fstype, dest, flags, data)
+
+/*
+ * Improper substitutions:
+ * The following macros are temporary replacements for functions
+ * and macros that exist on Linux and do not exist on FreeBSD.
+ */
+
+#define ETIME ETIMEDOUT
+
+#define MAP_POPULATE MAP_PREFAULT_READ
+
+#define MADV_HUGEPAGE MADV_SEQUENTIAL
+#define MADV_DONTFORK MADV_NOSYNC
+
+#define WDIOC_KEEPALIVE WDIOCPATPAT
+
+#define SCHED_RESET_ON_FORK 0
+#define SCHED_IDLE SCHED_OTHER
+
+#define gettid() getpid()
+
+#define pthread_sigqueue(pid, signo, value) \
+ sigqueue(pid, signo, value)
+
+#define signalfd(fd, mask, flags) -ENOSYS
+#define timerfd_create(c, f) -ENOSYS
+#define timerfd_settime(fd, f, n, o) -ENOSYS
+
+/*
+ * Macro conflict resolution.
+ */
+
+#undef ALIGN
+#undef PAGE_SIZE
+
+struct signalfd_siginfo {
+ uint32_t ssi_signo;
+ uint32_t ssi_pid;
+};
+
+struct kmod_module {
+ size_t size;
+};
+
+typedef struct {
+ char state;
+} proc_t;
+
+#endif /* IGT_FREEBSD_H */
diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
index f98dd29f..6596092b 100644
--- a/lib/igt_kmod.h
+++ b/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/lib/igt_kms.c b/lib/igt_kms.c
index 665594aa..532a3aa8 100644
--- a/lib/igt_kms.c
+++ b/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/lib/igt_os.c b/lib/igt_os.c
index bdd5d933..bb6994e1 100644
--- a/lib/igt_os.c
+++ b/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__)
+ 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__)
+ 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/lib/igt_perf.c b/lib/igt_perf.c
index b743859f..11c91c5f 100644
--- a/lib/igt_perf.c
+++ b/lib/igt_perf.c
@@ -4,8 +4,10 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysinfo.h>
#include <sys/sysmacros.h>
+#endif
#include <time.h>
#include <unistd.h>
diff --git a/lib/igt_perf.h b/lib/igt_perf.h
index a8328c70..0cd91386 100644
--- a/lib/igt_perf.h
+++ b/lib/igt_perf.h
@@ -27,10 +27,13 @@
#include <stdint.h>
+#ifdef __linux__
#include <linux/perf_event.h>
+#endif
#include "igt_gt.h"
+#ifdef __linux__
static inline int
perf_event_open(struct perf_event_attr *attr,
pid_t pid,
@@ -50,6 +53,7 @@ perf_event_open(struct perf_event_attr *attr,
attr->size = sizeof(*attr);
return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);
}
+#endif /* __linux__ */
uint64_t igt_perf_type_id(const char *device);
int igt_perf_open(uint64_t type, uint64_t config);
diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 312288d0..1e6e9ed3 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,7 +33,9 @@
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysmacros.h>
+#endif
#include <sys/types.h>
#include <dirent.h>
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 9c307694..a913be4c 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -24,7 +24,9 @@
#include <inttypes.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysmacros.h>
+#endif
#include <sys/mount.h>
#include <errno.h>
#include <stdarg.h>
diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
index 892a7f14..d2381944 100644
--- a/lib/tests/igt_exit_handler.c
+++ b/lib/tests/igt_exit_handler.c
@@ -125,5 +125,9 @@ int main(int argc, char **argv)
internal_assert_wexited(status, IGT_EXIT_SKIP);
status = testfunc(SIG);
+#ifdef __linux__
internal_assert_wsignaled(status, SIGTERM);
+#elif defined(__FreeBSD__)
+ internal_assert(status == 0);
+#endif
}
diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
index d19d0945..c7193b06 100644
--- a/lib/tests/igt_fork.c
+++ b/lib/tests/igt_fork.c
@@ -109,7 +109,7 @@ __noreturn static void igt_fork_timeout_leak(void)
__noreturn static void subtest_leak(void)
{
pid_t *children =
- mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+ mmap(0, 4096, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANON, -1, 0);
const int num_children = 4096 / sizeof(*children);
igt_subtest_init(fake_argc, fake_argv);
diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
index 058f6265..e8183897 100644
--- a/lib/tests/igt_tests_common.h
+++ b/lib/tests/igt_tests_common.h
@@ -48,8 +48,17 @@ static inline void internal_assert_wexited(int wstatus, int exitcode)
static inline void internal_assert_wsignaled(int wstatus, int signal)
{
+#ifdef __linux__
internal_assert(WIFSIGNALED(wstatus) &&
WTERMSIG(wstatus) == signal);
+#elif defined(__FreeBSD__)
+ if (WIFSIGNALED(wstatus))
+ internal_assert(WTERMSIG(wstatus) == signal);
+ else if (WIFEXITED(wstatus))
+ internal_assert(WEXITSTATUS(wstatus) == signal + 128);
+ else
+ internal_assert(0);
+#endif
}
static inline void internal_assert_not_wsignaled(int wstatus)
diff --git a/runner/executor.c b/runner/executor.c
index 964d0063..c54072cf 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -2,7 +2,9 @@
#include <errno.h>
#include <fcntl.h>
#include <glib.h>
+#ifdef __linux__
#include <linux/watchdog.h>
+#endif
#if HAVE_OPING
#include <oping.h>
#endif
@@ -33,6 +35,10 @@
#define KMSG_HEADER "[IGT] "
#define KMSG_WARN 4
+#ifdef __FreeBSD__
+#include <sys/watchdog.h>
+#endif
+
static struct {
int *fds;
size_t num_dogs;
diff --git a/runner/job_list.c b/runner/job_list.c
index 520a98da..6bfa7162 100644
--- a/runner/job_list.c
+++ b/runner/job_list.c
@@ -1,7 +1,12 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <sys/wait.h>
+#include <limits.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
index 938fde8f..42fe1657 100644
--- a/tests/i915/gem_close_race.c
+++ b/tests/i915/gem_close_race.c
@@ -61,7 +61,9 @@ static bool has_softpin;
static uint64_t exec_addr;
static uint64_t data_addr;
+#ifdef __linux__
#define sigev_notify_thread_id _sigev_un._tid
+#endif
static void selfcopy(int fd, uint32_t ctx, uint32_t handle, int loops)
{
diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
index e39b9047..4f05eb18 100644
--- a/tests/i915/gem_mmap_gtt.c
+++ b/tests/i915/gem_mmap_gtt.c
@@ -566,7 +566,7 @@ test_ptrace(int fd)
for (int i = 0; i < sz / sizeof(long); i++) {
long ret;
- ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i);
+ ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i, NULL);
igt_assert_eq_u64(ret, CC);
cpy[i] = ret;
diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
index 7e8c02d1..fc4245f6 100644
--- a/tests/i915/gem_mmap_offset.c
+++ b/tests/i915/gem_mmap_offset.c
@@ -520,7 +520,7 @@ static void test_ptrace(int i915)
for (int i = 0; i < SZ / sizeof(long); i++) {
long ret;
- ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i);
+ ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i, NULL);
igt_assert_eq_u64(ret, CC);
cpy[i] = ret;
diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c
index 4c72157c..9bec4c18 100644
--- a/tests/i915/i915_module_load.c
+++ b/tests/i915/i915_module_load.c
@@ -23,7 +23,9 @@
#include "igt.h"
#include <dirent.h>
#include <sys/utsname.h>
+#ifdef __linux__
#include <linux/limits.h>
+#endif
#include <signal.h>
#include <libgen.h>
#include <signal.h>
diff --git a/tests/i915/i915_pm_backlight.c b/tests/i915/i915_pm_backlight.c
index cafae7f7..c520cf20 100644
--- a/tests/i915/i915_pm_backlight.c
+++ b/tests/i915/i915_pm_backlight.c
@@ -46,6 +46,10 @@ struct context {
#define FADESTEPS 10
#define FADESPEED 100 /* milliseconds between steps */
+#ifdef __FreeBSD__
+#include <libgen.h>
+#endif
+
IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
static int backlight_read(int *result, const char *fname)
diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
index e95875dc..761e76f9 100644
--- a/tests/i915/i915_pm_rpm.c
+++ b/tests/i915/i915_pm_rpm.c
@@ -40,8 +40,10 @@
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
+#endif
#include <drm.h>
@@ -54,6 +56,12 @@
#include "igt_device.h"
#include "igt_edid.h"
+#ifdef __FreeBSD__
+#include <limits.h>
+#include <dev/iicbus/iic.h>
+#define addr slave
+#endif
+
#define MSR_PC8_RES 0x630
#define MSR_PC9_RES 0x631
#define MSR_PC10_RES 0x632
diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
index 3041f1cd..e0e5af78 100644
--- a/tests/kms_content_protection.c
+++ b/tests/kms_content_protection.c
@@ -24,7 +24,9 @@
#include <poll.h>
#include <fcntl.h>
+#ifdef __linux__
#include <sys/epoll.h>
+#endif
#include <sys/stat.h>
#include <libudev.h>
#include "igt.h"
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 0567edea..1127e418 100755
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -45,6 +45,10 @@
#include "i915/gem_create.h"
#include "igt_stats.h"
+#ifdef __FreeBSD__
+#include <sys/consio.h>
+#endif
+
#define TEST_DPMS (1 << 0)
#define TEST_PAN (1 << 3)
diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
index 77521108..cd980c6a 100644
--- a/tests/kms_sysfs_edid_timing.c
+++ b/tests/kms_sysfs_edid_timing.c
@@ -26,6 +26,10 @@
#include <fcntl.h>
#include <sys/stat.h>
+#ifdef __FreeBSD__
+#include <limits.h>
+#endif
+
#define THRESHOLD_PER_CONNECTOR 150
#define THRESHOLD_PER_CONNECTOR_MEAN 140
#define THRESHOLD_ALL_CONNECTORS_MEAN 100
diff --git a/tests/tools_test.c b/tests/tools_test.c
index 237f0433..89a19d11 100644
--- a/tests/tools_test.c
+++ b/tests/tools_test.c
@@ -28,7 +28,11 @@
#include <fcntl.h>
#include <libgen.h>
#include <unistd.h>
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <limits.h>
+#endif
#define TOOLS "../tools/"
diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c
index ad5ee6a6..3e53c6d9 100644
--- a/tools/intel_gvtg_test.c
+++ b/tools/intel_gvtg_test.c
@@ -55,6 +55,10 @@
#include <limits.h>
#include <dirent.h>
+#ifdef __FreeBSD__
+#include <sys/wait.h>
+#endif
+
#define RANDOM(x) (rand() % x)
--
2.37.0 (Apple Git-136)
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [igt-dev] ✓ Fi.CI.BAT: success for Introduced partial FreeBSD compatibility (rev8)
2022-10-06 2:23 [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility Jake Freeland
@ 2022-10-06 3:24 ` Patchwork
2022-10-06 7:59 ` [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility Petri Latvala
` (2 subsequent siblings)
3 siblings, 0 replies; 20+ messages in thread
From: Patchwork @ 2022-10-06 3:24 UTC (permalink / raw)
To: Jake Freeland; +Cc: igt-dev
[-- Attachment #1: Type: text/plain, Size: 6939 bytes --]
== Series Details ==
Series: Introduced partial FreeBSD compatibility (rev8)
URL : https://patchwork.freedesktop.org/series/108081/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_12221 -> IGTPW_7917
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/index.html
Participating hosts (43 -> 41)
------------------------------
Additional (2): bat-atsm-1 fi-tgl-dsi
Missing (4): fi-ctg-p8600 fi-hsw-4200u fi-hsw-g3258 fi-snb-2600
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in IGTPW_7917:
### IGT changes ###
#### Suppressed ####
The following results come from untrusted machines, tests, or statuses.
They do not affect the overall result.
* igt@i915_pm_rpm@basic-rte:
- {bat-rplp-1}: [PASS][1] -> [DMESG-WARN][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/bat-rplp-1/igt@i915_pm_rpm@basic-rte.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/bat-rplp-1/igt@i915_pm_rpm@basic-rte.html
* igt@i915_suspend@basic-s2idle-without-i915:
- {bat-dg2-9}: [PASS][3] -> [WARN][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/bat-dg2-9/igt@i915_suspend@basic-s2idle-without-i915.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/bat-dg2-9/igt@i915_suspend@basic-s2idle-without-i915.html
Known issues
------------
Here are the changes found in IGTPW_7917 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@kms_chamelium@common-hpd-after-suspend:
- fi-apl-guc: NOTRUN -> [SKIP][5] ([fdo#109271] / [fdo#111827])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/fi-apl-guc/igt@kms_chamelium@common-hpd-after-suspend.html
#### Possible fixes ####
* igt@i915_pm_rpm@module-reload:
- {bat-rpls-2}: [DMESG-WARN][6] ([i915#5537]) -> [PASS][7]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/bat-rpls-2/igt@i915_pm_rpm@module-reload.html
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/bat-rpls-2/igt@i915_pm_rpm@module-reload.html
* igt@i915_selftest@live@migrate:
- fi-apl-guc: [INCOMPLETE][8] -> [PASS][9]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/fi-apl-guc/igt@i915_selftest@live@migrate.html
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/fi-apl-guc/igt@i915_selftest@live@migrate.html
* igt@i915_selftest@live@mman:
- {bat-dg2-8}: [INCOMPLETE][10] ([i915#6797]) -> [PASS][11]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/bat-dg2-8/igt@i915_selftest@live@mman.html
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/bat-dg2-8/igt@i915_selftest@live@mman.html
* igt@i915_selftest@live@reset:
- {bat-rpls-1}: [DMESG-FAIL][12] ([i915#4983]) -> [PASS][13]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/bat-rpls-1/igt@i915_selftest@live@reset.html
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/bat-rpls-1/igt@i915_selftest@live@reset.html
- {bat-rpls-2}: [DMESG-FAIL][14] ([i915#5828]) -> [PASS][15]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/bat-rpls-2/igt@i915_selftest@live@reset.html
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/bat-rpls-2/igt@i915_selftest@live@reset.html
* igt@kms_force_connector_basic@force-connector-state:
- fi-cfl-8109u: [DMESG-WARN][16] ([i915#62]) -> [PASS][17]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/fi-cfl-8109u/igt@kms_force_connector_basic@force-connector-state.html
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/fi-cfl-8109u/igt@kms_force_connector_basic@force-connector-state.html
* igt@kms_pipe_crc_basic@suspend-read-crc@pipe-d-dp-2:
- {bat-dg2-11}: [FAIL][18] ([i915#6818]) -> [PASS][19] +1 similar issue
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/bat-dg2-11/igt@kms_pipe_crc_basic@suspend-read-crc@pipe-d-dp-2.html
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/bat-dg2-11/igt@kms_pipe_crc_basic@suspend-read-crc@pipe-d-dp-2.html
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109284]: https://bugs.freedesktop.org/show_bug.cgi?id=109284
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109295]: https://bugs.freedesktop.org/show_bug.cgi?id=109295
[fdo#110189]: https://bugs.freedesktop.org/show_bug.cgi?id=110189
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#2582]: https://gitlab.freedesktop.org/drm/intel/issues/2582
[i915#3301]: https://gitlab.freedesktop.org/drm/intel/issues/3301
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
[i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
[i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
[i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
[i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#4983]: https://gitlab.freedesktop.org/drm/intel/issues/4983
[i915#5354]: https://gitlab.freedesktop.org/drm/intel/issues/5354
[i915#5537]: https://gitlab.freedesktop.org/drm/intel/issues/5537
[i915#5828]: https://gitlab.freedesktop.org/drm/intel/issues/5828
[i915#62]: https://gitlab.freedesktop.org/drm/intel/issues/62
[i915#6367]: https://gitlab.freedesktop.org/drm/intel/issues/6367
[i915#6559]: https://gitlab.freedesktop.org/drm/intel/issues/6559
[i915#6645]: https://gitlab.freedesktop.org/drm/intel/issues/6645
[i915#6797]: https://gitlab.freedesktop.org/drm/intel/issues/6797
[i915#6818]: https://gitlab.freedesktop.org/drm/intel/issues/6818
[i915#6856]: https://gitlab.freedesktop.org/drm/intel/issues/6856
[i915#6997]: https://gitlab.freedesktop.org/drm/intel/issues/6997
[i915#7030]: https://gitlab.freedesktop.org/drm/intel/issues/7030
Build changes
-------------
* CI: CI-20190529 -> None
* IGT: IGT_7000 -> IGTPW_7917
CI-20190529: 20190529
CI_DRM_12221: 473f3064abe6fbdd81fc696215a853ec44ed4b8f @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_7917: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/index.html
IGT_7000: 17292ab1e63802d8456670f606f8ad78082d09ee @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/index.html
[-- Attachment #2: Type: text/html, Size: 6299 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility
2022-10-06 2:23 [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility Jake Freeland
2022-10-06 3:24 ` [igt-dev] ✓ Fi.CI.BAT: success for Introduced partial FreeBSD compatibility (rev8) Patchwork
@ 2022-10-06 7:59 ` Petri Latvala
2022-10-06 15:49 ` Jake Freeland
2022-10-06 12:50 ` Kamil Konieczny
2022-10-06 17:25 ` [igt-dev] ✗ Fi.CI.IGT: failure for Introduced partial FreeBSD compatibility (rev8) Patchwork
3 siblings, 1 reply; 20+ messages in thread
From: Petri Latvala @ 2022-10-06 7:59 UTC (permalink / raw)
To: Jake Freeland; +Cc: igt-dev, Jake Freeland
On Wed, Oct 05, 2022 at 09:23:29PM -0500, Jake Freeland wrote:
> FreeBSD's Linux compatbility layer, LinuxKPI, has introduced
> modern drm drivers to the FreeBSD desktop. With drm drivers,
> comes the need for drm testing. This patch allows a portion
> of igt-gpu-tools to compile on FreeBSD
>
> Signed-off-by: Jake Freeland <jfree@freebsd.org>
> ---
> benchmarks/gem_exec_tracer.c | 4 ++
> benchmarks/gem_syslatency.c | 6 ++
> include/linux-uapi/sync_file.h | 5 ++
> lib/i915/intel_memory_region.c | 4 ++
> lib/i915/perf.c | 2 +
> lib/igt_audio.c | 4 ++
> lib/igt_aux.c | 2 +
> lib/igt_aux.h | 6 +-
> lib/igt_core.c | 11 ++-
> lib/igt_core.h | 8 +++
> lib/igt_debugfs.c | 2 +
> lib/igt_device.c | 2 +
> lib/igt_device_scan.c | 4 ++
> lib/igt_eld.c | 4 ++
> lib/igt_frame.c | 4 ++
> lib/igt_freebsd.h | 123 +++++++++++++++++++++++++++++++++
> lib/igt_kmod.h | 2 +
> lib/igt_kms.c | 4 ++
> lib/igt_os.c | 19 +++++
> lib/igt_perf.c | 2 +
> lib/igt_perf.h | 4 ++
> lib/igt_pm.c | 2 +
> lib/igt_sysfs.c | 2 +
> lib/tests/igt_exit_handler.c | 4 ++
> lib/tests/igt_fork.c | 2 +-
> lib/tests/igt_tests_common.h | 9 +++
> runner/executor.c | 6 ++
> runner/job_list.c | 5 ++
> tests/i915/gem_close_race.c | 2 +
> tests/i915/gem_mmap_gtt.c | 2 +-
> tests/i915/gem_mmap_offset.c | 2 +-
> tests/i915/i915_module_load.c | 2 +
> tests/i915/i915_pm_backlight.c | 4 ++
> tests/i915/i915_pm_rpm.c | 8 +++
> tests/kms_content_protection.c | 2 +
> tests/kms_flip.c | 4 ++
> tests/kms_sysfs_edid_timing.c | 4 ++
> tests/tools_test.c | 4 ++
> tools/intel_gvtg_test.c | 4 ++
> 39 files changed, 280 insertions(+), 10 deletions(-)
> create mode 100644 lib/igt_freebsd.h
>
> diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
> index e6973991..7e86473e 100644
> --- a/benchmarks/gem_exec_tracer.c
> +++ b/benchmarks/gem_exec_tracer.c
> @@ -41,6 +41,10 @@
> #include "intel_aub.h"
> #include "intel_chipset.h"
>
> +#ifdef __FreeBSD__
> +#include "igt_freebsd.h"
> +#endif
> +
> static int (*libc_close)(int fd);
> static int (*libc_ioctl)(int fd, unsigned long request, void *argp);
>
> diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
> index 035ee934..dafc6ac0 100644
> --- a/benchmarks/gem_syslatency.c
> +++ b/benchmarks/gem_syslatency.c
> @@ -42,12 +42,18 @@
> #include <limits.h>
> #include "drm.h"
>
> +#ifdef __linux__
> #include <linux/unistd.h>
> +#elif defined(__FreeBSD__)
> +#include "igt_freebsd.h"
> +#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/include/linux-uapi/sync_file.h b/include/linux-uapi/sync_file.h
> index b4f2db00..270c1cbc 100644
> --- a/include/linux-uapi/sync_file.h
> +++ b/include/linux-uapi/sync_file.h
> @@ -12,8 +12,13 @@
> #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 "igt_freebsd.h"
> +#endif
>
> /**
> * struct sync_merge_data - data passed to merge ioctl
> diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
> index 568bace9..0a59f290 100644
> --- a/lib/i915/intel_memory_region.c
> +++ b/lib/i915/intel_memory_region.c
> @@ -21,7 +21,11 @@
> * IN THE SOFTWARE.
> */
>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#elif defined(__FreeBSD__)
> +#include <limits.h>
> +#endif
> #include <signal.h>
> #include <sys/ioctl.h>
> #include <sys/time.h>
> diff --git a/lib/i915/perf.c b/lib/i915/perf.c
> index d88835ff..beda6b8a 100644
> --- a/lib/i915/perf.c
> +++ b/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/lib/igt_audio.c b/lib/igt_audio.c
> index e0b1bafe..201a39c6 100644
> --- a/lib/igt_audio.c
> +++ b/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/lib/igt_aux.c b/lib/igt_aux.c
> index edb53425..d7e2714f 100644
> --- a/lib/igt_aux.c
> +++ b/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"
> diff --git a/lib/igt_aux.h b/lib/igt_aux.h
> index c8d487b6..912f36c1 100644
> --- a/lib/igt_aux.h
> +++ b/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/lib/igt_core.c b/lib/igt_core.c
> index e7425326..b4b8877f 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -43,9 +43,7 @@
> #include <unistd.h>
> #include <sys/wait.h>
> #include <sys/types.h>
> -#ifdef __linux__
> #include <sys/syscall.h>
> -#endif
> #include <pthread.h>
> #include <sys/utsname.h>
> #include <termios.h>
> @@ -786,6 +784,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
>
> static void oom_adjust_for_doom(void)
> {
> +#ifdef __linux__
> int fd;
> const char always_kill[] = "1000";
>
> @@ -793,7 +792,13 @@ 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);
> -
> +#elif defined(__FreeBSD__)
> + /*
> + * oom_score_adj not present in FreeBSD's linprocfs.
> + * Stop process directly instead.
> + */
> + raise(SIGTERM);
> +#endif
You have a misunderstanding here. oom_adjust_for_doom() doesn't make
the process die _now_. It gives the kernel a hint that _if_
out-of-memory hits, "I volunteer as tribute".
--
Petri Latvala
> }
>
> /**
> diff --git a/lib/igt_core.h b/lib/igt_core.h
> index aa98e8ed..cc382497 100644
> --- a/lib/igt_core.h
> +++ b/lib/igt_core.h
> @@ -31,7 +31,11 @@
> #define IGT_CORE_H
>
> #include <assert.h>
> +#ifdef __linux__
> #include <byteswap.h>
> +#elif defined(__FreeBSD__)
> +#include <sys/endian.h>
> +#endif
> #include <setjmp.h>
> #include <stdbool.h>
> #include <stdint.h>
> @@ -43,6 +47,10 @@
> #include <getopt.h>
> #include <unistd.h>
>
> +#ifdef __FreeBSD__
> +#include "igt_freebsd.h"
> +#endif
> +
> #ifndef IGT_LOG_DOMAIN
> #define IGT_LOG_DOMAIN (NULL)
> #endif
> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> index a56688a5..fa1e3b69 100644
> --- a/lib/igt_debugfs.c
> +++ b/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>
> diff --git a/lib/igt_device.c b/lib/igt_device.c
> index fddfba72..49b77122 100644
> --- a/lib/igt_device.c
> +++ b/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/lib/igt_device_scan.c b/lib/igt_device_scan.c
> index eb6b45b8..6a921d52 100644
> --- a/lib/igt_device_scan.c
> +++ b/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/lib/igt_eld.c b/lib/igt_eld.c
> index ef6625df..e05ad6de 100644
> --- a/lib/igt_eld.c
> +++ b/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/lib/igt_frame.c b/lib/igt_frame.c
> index 45523a79..ab74e678 100644
> --- a/lib/igt_frame.c
> +++ b/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/lib/igt_freebsd.h b/lib/igt_freebsd.h
> new file mode 100644
> index 00000000..de349148
> --- /dev/null
> +++ b/lib/igt_freebsd.h
> @@ -0,0 +1,123 @@
> +/*
> + * SPDX-License-Identifier: MIT
> + *
> + * Copyright (c) 2022, Jake Freeland <jfree@FreeBSD.org>
> + *
> + * 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.
> + */
> +
> +#if !defined(IGT_FREEBSD_H) && defined(__FreeBSD__)
> +#define IGT_FREEBSD_H
> +
> +#include <sys/errno.h>
> +#include <sys/mman.h>
> +#include <sys/mount.h>
> +#include <sys/sched.h>
> +#include <sys/types.h>
> +#include <sys/watchdog.h>
> +
> +#include <pthread.h>
> +#include <setjmp.h>
> +#include <signal.h>
> +#include <unistd.h>
> +
> +/*
> + * Proper substitutions:
> + * The following macros replace Linux-specific functions
> + * and macros with their FreeBSD equivalents.
> + */
> +
> +#define __s32 int32_t
> +#define __u32 uint32_t
> +#define __u64 uint64_t
> +
> +#define sighandler_t sig_t
> +#define ino64_t ino_t
> +
> +#define jmp_buf sigjmp_buf
> +
> +#define PTRACE_TRACEME PT_TRACE_ME
> +#define PTRACE_ATTACH PT_ATTACH
> +#define PTRACE_PEEKDATA PT_READ_D
> +#define PTRACE_POKEDATA PT_WRITE_D
> +#define PTRACE_DETACH PT_DETACH
> +
> +#define I2C_RDWR I2CRDWR
> +#define I2C_M_RD IIC_M_RD
> +#define i2c_msg iic_msg
> +#define i2c_rdwr_ioctl_data iic_rdwr_data
> +
> +#define bswap_32(x) bswap32(x)
> +
> +#define _IOC_TYPE(nr) (((nr) >> 8) & 255)
> +
> +#define SYS_getdents64 SYS_freebsd11_getdents
> +
> +#define mount(src, dest, fstype, flags, data) \
> + mount(fstype, dest, flags, data)
> +
> +/*
> + * Improper substitutions:
> + * The following macros are temporary replacements for functions
> + * and macros that exist on Linux and do not exist on FreeBSD.
> + */
> +
> +#define ETIME ETIMEDOUT
> +
> +#define MAP_POPULATE MAP_PREFAULT_READ
> +
> +#define MADV_HUGEPAGE MADV_SEQUENTIAL
> +#define MADV_DONTFORK MADV_NOSYNC
> +
> +#define WDIOC_KEEPALIVE WDIOCPATPAT
> +
> +#define SCHED_RESET_ON_FORK 0
> +#define SCHED_IDLE SCHED_OTHER
> +
> +#define gettid() getpid()
> +
> +#define pthread_sigqueue(pid, signo, value) \
> + sigqueue(pid, signo, value)
> +
> +#define signalfd(fd, mask, flags) -ENOSYS
> +#define timerfd_create(c, f) -ENOSYS
> +#define timerfd_settime(fd, f, n, o) -ENOSYS
> +
> +/*
> + * Macro conflict resolution.
> + */
> +
> +#undef ALIGN
> +#undef PAGE_SIZE
> +
> +struct signalfd_siginfo {
> + uint32_t ssi_signo;
> + uint32_t ssi_pid;
> +};
> +
> +struct kmod_module {
> + size_t size;
> +};
> +
> +typedef struct {
> + char state;
> +} proc_t;
> +
> +#endif /* IGT_FREEBSD_H */
> diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
> index f98dd29f..6596092b 100644
> --- a/lib/igt_kmod.h
> +++ b/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/lib/igt_kms.c b/lib/igt_kms.c
> index 665594aa..532a3aa8 100644
> --- a/lib/igt_kms.c
> +++ b/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/lib/igt_os.c b/lib/igt_os.c
> index bdd5d933..bb6994e1 100644
> --- a/lib/igt_os.c
> +++ b/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__)
> + 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__)
> + 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/lib/igt_perf.c b/lib/igt_perf.c
> index b743859f..11c91c5f 100644
> --- a/lib/igt_perf.c
> +++ b/lib/igt_perf.c
> @@ -4,8 +4,10 @@
> #include <stdlib.h>
> #include <string.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <sys/sysinfo.h>
> #include <sys/sysmacros.h>
> +#endif
> #include <time.h>
> #include <unistd.h>
>
> diff --git a/lib/igt_perf.h b/lib/igt_perf.h
> index a8328c70..0cd91386 100644
> --- a/lib/igt_perf.h
> +++ b/lib/igt_perf.h
> @@ -27,10 +27,13 @@
>
> #include <stdint.h>
>
> +#ifdef __linux__
> #include <linux/perf_event.h>
> +#endif
>
> #include "igt_gt.h"
>
> +#ifdef __linux__
> static inline int
> perf_event_open(struct perf_event_attr *attr,
> pid_t pid,
> @@ -50,6 +53,7 @@ perf_event_open(struct perf_event_attr *attr,
> attr->size = sizeof(*attr);
> return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);
> }
> +#endif /* __linux__ */
>
> uint64_t igt_perf_type_id(const char *device);
> int igt_perf_open(uint64_t type, uint64_t config);
> diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> index 312288d0..1e6e9ed3 100644
> --- a/lib/igt_pm.c
> +++ b/lib/igt_pm.c
> @@ -33,7 +33,9 @@
> #include <string.h>
> #include <unistd.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <sys/sysmacros.h>
> +#endif
> #include <sys/types.h>
> #include <dirent.h>
>
> diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
> index 9c307694..a913be4c 100644
> --- a/lib/igt_sysfs.c
> +++ b/lib/igt_sysfs.c
> @@ -24,7 +24,9 @@
>
> #include <inttypes.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <sys/sysmacros.h>
> +#endif
> #include <sys/mount.h>
> #include <errno.h>
> #include <stdarg.h>
> diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
> index 892a7f14..d2381944 100644
> --- a/lib/tests/igt_exit_handler.c
> +++ b/lib/tests/igt_exit_handler.c
> @@ -125,5 +125,9 @@ int main(int argc, char **argv)
> internal_assert_wexited(status, IGT_EXIT_SKIP);
>
> status = testfunc(SIG);
> +#ifdef __linux__
> internal_assert_wsignaled(status, SIGTERM);
> +#elif defined(__FreeBSD__)
> + internal_assert(status == 0);
> +#endif
> }
> diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
> index d19d0945..c7193b06 100644
> --- a/lib/tests/igt_fork.c
> +++ b/lib/tests/igt_fork.c
> @@ -109,7 +109,7 @@ __noreturn static void igt_fork_timeout_leak(void)
> __noreturn static void subtest_leak(void)
> {
> pid_t *children =
> - mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
> + mmap(0, 4096, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANON, -1, 0);
> const int num_children = 4096 / sizeof(*children);
>
> igt_subtest_init(fake_argc, fake_argv);
> diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
> index 058f6265..e8183897 100644
> --- a/lib/tests/igt_tests_common.h
> +++ b/lib/tests/igt_tests_common.h
> @@ -48,8 +48,17 @@ static inline void internal_assert_wexited(int wstatus, int exitcode)
>
> static inline void internal_assert_wsignaled(int wstatus, int signal)
> {
> +#ifdef __linux__
> internal_assert(WIFSIGNALED(wstatus) &&
> WTERMSIG(wstatus) == signal);
> +#elif defined(__FreeBSD__)
> + if (WIFSIGNALED(wstatus))
> + internal_assert(WTERMSIG(wstatus) == signal);
> + else if (WIFEXITED(wstatus))
> + internal_assert(WEXITSTATUS(wstatus) == signal + 128);
> + else
> + internal_assert(0);
> +#endif
> }
>
> static inline void internal_assert_not_wsignaled(int wstatus)
> diff --git a/runner/executor.c b/runner/executor.c
> index 964d0063..c54072cf 100644
> --- a/runner/executor.c
> +++ b/runner/executor.c
> @@ -2,7 +2,9 @@
> #include <errno.h>
> #include <fcntl.h>
> #include <glib.h>
> +#ifdef __linux__
> #include <linux/watchdog.h>
> +#endif
> #if HAVE_OPING
> #include <oping.h>
> #endif
> @@ -33,6 +35,10 @@
> #define KMSG_HEADER "[IGT] "
> #define KMSG_WARN 4
>
> +#ifdef __FreeBSD__
> +#include <sys/watchdog.h>
> +#endif
> +
> static struct {
> int *fds;
> size_t num_dogs;
> diff --git a/runner/job_list.c b/runner/job_list.c
> index 520a98da..6bfa7162 100644
> --- a/runner/job_list.c
> +++ b/runner/job_list.c
> @@ -1,7 +1,12 @@
> #include <ctype.h>
> #include <errno.h>
> #include <fcntl.h>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#elif defined(__FreeBSD__)
> +#include <sys/wait.h>
> +#include <limits.h>
> +#endif
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
> index 938fde8f..42fe1657 100644
> --- a/tests/i915/gem_close_race.c
> +++ b/tests/i915/gem_close_race.c
> @@ -61,7 +61,9 @@ static bool has_softpin;
> static uint64_t exec_addr;
> static uint64_t data_addr;
>
> +#ifdef __linux__
> #define sigev_notify_thread_id _sigev_un._tid
> +#endif
>
> static void selfcopy(int fd, uint32_t ctx, uint32_t handle, int loops)
> {
> diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
> index e39b9047..4f05eb18 100644
> --- a/tests/i915/gem_mmap_gtt.c
> +++ b/tests/i915/gem_mmap_gtt.c
> @@ -566,7 +566,7 @@ test_ptrace(int fd)
> for (int i = 0; i < sz / sizeof(long); i++) {
> long ret;
>
> - ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i);
> + ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i, NULL);
> igt_assert_eq_u64(ret, CC);
> cpy[i] = ret;
>
> diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
> index 7e8c02d1..fc4245f6 100644
> --- a/tests/i915/gem_mmap_offset.c
> +++ b/tests/i915/gem_mmap_offset.c
> @@ -520,7 +520,7 @@ static void test_ptrace(int i915)
> for (int i = 0; i < SZ / sizeof(long); i++) {
> long ret;
>
> - ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i);
> + ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i, NULL);
> igt_assert_eq_u64(ret, CC);
> cpy[i] = ret;
>
> diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c
> index 4c72157c..9bec4c18 100644
> --- a/tests/i915/i915_module_load.c
> +++ b/tests/i915/i915_module_load.c
> @@ -23,7 +23,9 @@
> #include "igt.h"
> #include <dirent.h>
> #include <sys/utsname.h>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#endif
> #include <signal.h>
> #include <libgen.h>
> #include <signal.h>
> diff --git a/tests/i915/i915_pm_backlight.c b/tests/i915/i915_pm_backlight.c
> index cafae7f7..c520cf20 100644
> --- a/tests/i915/i915_pm_backlight.c
> +++ b/tests/i915/i915_pm_backlight.c
> @@ -46,6 +46,10 @@ struct context {
> #define FADESTEPS 10
> #define FADESPEED 100 /* milliseconds between steps */
>
> +#ifdef __FreeBSD__
> +#include <libgen.h>
> +#endif
> +
> IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
>
> static int backlight_read(int *result, const char *fname)
> diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
> index e95875dc..761e76f9 100644
> --- a/tests/i915/i915_pm_rpm.c
> +++ b/tests/i915/i915_pm_rpm.c
> @@ -40,8 +40,10 @@
> #include <sys/mman.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <linux/i2c.h>
> #include <linux/i2c-dev.h>
> +#endif
>
> #include <drm.h>
>
> @@ -54,6 +56,12 @@
> #include "igt_device.h"
> #include "igt_edid.h"
>
> +#ifdef __FreeBSD__
> +#include <limits.h>
> +#include <dev/iicbus/iic.h>
> +#define addr slave
> +#endif
> +
> #define MSR_PC8_RES 0x630
> #define MSR_PC9_RES 0x631
> #define MSR_PC10_RES 0x632
> diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
> index 3041f1cd..e0e5af78 100644
> --- a/tests/kms_content_protection.c
> +++ b/tests/kms_content_protection.c
> @@ -24,7 +24,9 @@
>
> #include <poll.h>
> #include <fcntl.h>
> +#ifdef __linux__
> #include <sys/epoll.h>
> +#endif
> #include <sys/stat.h>
> #include <libudev.h>
> #include "igt.h"
> diff --git a/tests/kms_flip.c b/tests/kms_flip.c
> index 0567edea..1127e418 100755
> --- a/tests/kms_flip.c
> +++ b/tests/kms_flip.c
> @@ -45,6 +45,10 @@
> #include "i915/gem_create.h"
> #include "igt_stats.h"
>
> +#ifdef __FreeBSD__
> +#include <sys/consio.h>
> +#endif
> +
> #define TEST_DPMS (1 << 0)
>
> #define TEST_PAN (1 << 3)
> diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
> index 77521108..cd980c6a 100644
> --- a/tests/kms_sysfs_edid_timing.c
> +++ b/tests/kms_sysfs_edid_timing.c
> @@ -26,6 +26,10 @@
> #include <fcntl.h>
> #include <sys/stat.h>
>
> +#ifdef __FreeBSD__
> +#include <limits.h>
> +#endif
> +
> #define THRESHOLD_PER_CONNECTOR 150
> #define THRESHOLD_PER_CONNECTOR_MEAN 140
> #define THRESHOLD_ALL_CONNECTORS_MEAN 100
> diff --git a/tests/tools_test.c b/tests/tools_test.c
> index 237f0433..89a19d11 100644
> --- a/tests/tools_test.c
> +++ b/tests/tools_test.c
> @@ -28,7 +28,11 @@
> #include <fcntl.h>
> #include <libgen.h>
> #include <unistd.h>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#elif defined(__FreeBSD__)
> +#include <limits.h>
> +#endif
>
> #define TOOLS "../tools/"
>
> diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c
> index ad5ee6a6..3e53c6d9 100644
> --- a/tools/intel_gvtg_test.c
> +++ b/tools/intel_gvtg_test.c
> @@ -55,6 +55,10 @@
> #include <limits.h>
> #include <dirent.h>
>
> +#ifdef __FreeBSD__
> +#include <sys/wait.h>
> +#endif
> +
> #define RANDOM(x) (rand() % x)
>
>
> --
> 2.37.0 (Apple Git-136)
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility
2022-10-06 2:23 [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility Jake Freeland
2022-10-06 3:24 ` [igt-dev] ✓ Fi.CI.BAT: success for Introduced partial FreeBSD compatibility (rev8) Patchwork
2022-10-06 7:59 ` [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility Petri Latvala
@ 2022-10-06 12:50 ` Kamil Konieczny
2022-10-06 17:25 ` [igt-dev] ✗ Fi.CI.IGT: failure for Introduced partial FreeBSD compatibility (rev8) Patchwork
3 siblings, 0 replies; 20+ messages in thread
From: Kamil Konieczny @ 2022-10-06 12:50 UTC (permalink / raw)
To: igt-dev; +Cc: Petri Latvala, Jake Freeland
Hi Jake,
On 2022-10-05 at 21:23:29 -0500, Jake Freeland wrote:
> FreeBSD's Linux compatbility layer, LinuxKPI, has introduced
> modern drm drivers to the FreeBSD desktop. With drm drivers,
> comes the need for drm testing. This patch allows a portion
> of igt-gpu-tools to compile on FreeBSD
>
> Signed-off-by: Jake Freeland <jfree@freebsd.org>
> ---
> benchmarks/gem_exec_tracer.c | 4 ++
> benchmarks/gem_syslatency.c | 6 ++
> include/linux-uapi/sync_file.h | 5 ++
> lib/i915/intel_memory_region.c | 4 ++
> lib/i915/perf.c | 2 +
> lib/igt_audio.c | 4 ++
> lib/igt_aux.c | 2 +
> lib/igt_aux.h | 6 +-
> lib/igt_core.c | 11 ++-
> lib/igt_core.h | 8 +++
> lib/igt_debugfs.c | 2 +
> lib/igt_device.c | 2 +
> lib/igt_device_scan.c | 4 ++
> lib/igt_eld.c | 4 ++
> lib/igt_frame.c | 4 ++
> lib/igt_freebsd.h | 123 +++++++++++++++++++++++++++++++++
> lib/igt_kmod.h | 2 +
> lib/igt_kms.c | 4 ++
> lib/igt_os.c | 19 +++++
> lib/igt_perf.c | 2 +
> lib/igt_perf.h | 4 ++
> lib/igt_pm.c | 2 +
> lib/igt_sysfs.c | 2 +
> lib/tests/igt_exit_handler.c | 4 ++
> lib/tests/igt_fork.c | 2 +-
> lib/tests/igt_tests_common.h | 9 +++
> runner/executor.c | 6 ++
> runner/job_list.c | 5 ++
It would be best to put ifdef(__freebsd__) into headers
and libs, so no changes would be done to tests and maybe also to
benchmarks and tools.
> tests/i915/gem_close_race.c | 2 +
> tests/i915/gem_mmap_gtt.c | 2 +-
> tests/i915/gem_mmap_offset.c | 2 +-
> tests/i915/i915_module_load.c | 2 +
> tests/i915/i915_pm_backlight.c | 4 ++
> tests/i915/i915_pm_rpm.c | 8 +++
> tests/kms_content_protection.c | 2 +
> tests/kms_flip.c | 4 ++
> tests/kms_sysfs_edid_timing.c | 4 ++
> tests/tools_test.c | 4 ++
> tools/intel_gvtg_test.c | 4 ++
> 39 files changed, 280 insertions(+), 10 deletions(-)
> create mode 100644 lib/igt_freebsd.h
>
> diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
> index e6973991..7e86473e 100644
> --- a/benchmarks/gem_exec_tracer.c
> +++ b/benchmarks/gem_exec_tracer.c
> @@ -41,6 +41,10 @@
> #include "intel_aub.h"
> #include "intel_chipset.h"
>
> +#ifdef __FreeBSD__
> +#include "igt_freebsd.h"
> +#endif
> +
> static int (*libc_close)(int fd);
> static int (*libc_ioctl)(int fd, unsigned long request, void *argp);
>
> diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
> index 035ee934..dafc6ac0 100644
> --- a/benchmarks/gem_syslatency.c
> +++ b/benchmarks/gem_syslatency.c
> @@ -42,12 +42,18 @@
> #include <limits.h>
> #include "drm.h"
>
> +#ifdef __linux__
> #include <linux/unistd.h>
> +#elif defined(__FreeBSD__)
> +#include "igt_freebsd.h"
> +#endif
>
> #include "i915/gem_create.h"
> #include "i915/gem_ring.h"
>
> +#ifdef __linux__
> #define sigev_notify_thread_id _sigev_un._tid
> +#endif
Looks strange, maybe we should just put appropriate include
instead of this.
>
> static volatile int done;
>
> diff --git a/include/linux-uapi/sync_file.h b/include/linux-uapi/sync_file.h
> index b4f2db00..270c1cbc 100644
> --- a/include/linux-uapi/sync_file.h
> +++ b/include/linux-uapi/sync_file.h
Why do we need to touach this ? It will be better to not change
linux includes.
> @@ -12,8 +12,13 @@
> #ifndef _LINUX_SYNC_H
> #define _LINUX_SYNC_H
>
> +#ifdef __linux__
imho when there are chains, maybe it would be better to have
#if defined(__linux__)
> #include <linux/ioctl.h>
> #include <linux/types.h>
> +#elif defined(__FreeBSD__)
> +#include <sys/ioctl.h>
------------ ^
maybe put this inside igt_freebsd.h ?
> +#include "igt_freebsd.h"
> +#endif
Hmmm, maybe we should have igt_sync.h (or igt_sync_file.h ?)
because it looks strange to have __freebsd__ inside linux uAPI,
so maybe something like file include/sync_file.h
with content:
#if defined(__linux__)
#include <linux/sync_file.h>
#elif defined(__FreeBSD__)
#include <freebsd/sync_file.h>
#fi
Or even better, choose proper include folder at compilation ?
-I./include/linux-uapi/
or
-I./include/freebsd-uapi/
?
> +#include <sys/ioctl.h>
> +#include "igt_freebsd.h"
> +#endif
>
> /**
> * struct sync_merge_data - data passed to merge ioctl
> diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
> index 568bace9..0a59f290 100644
> --- a/lib/i915/intel_memory_region.c
> +++ b/lib/i915/intel_memory_region.c
> @@ -21,7 +21,11 @@
> * IN THE SOFTWARE.
> */
>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#elif defined(__FreeBSD__)
> +#include <limits.h>
> +#endif
> #include <signal.h>
> #include <sys/ioctl.h>
> #include <sys/time.h>
> diff --git a/lib/i915/perf.c b/lib/i915/perf.c
> index d88835ff..beda6b8a 100644
> --- a/lib/i915/perf.c
> +++ b/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/lib/igt_audio.c b/lib/igt_audio.c
> index e0b1bafe..201a39c6 100644
> --- a/lib/igt_audio.c
> +++ b/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/lib/igt_aux.c b/lib/igt_aux.c
> index edb53425..d7e2714f 100644
> --- a/lib/igt_aux.c
> +++ b/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"
> diff --git a/lib/igt_aux.h b/lib/igt_aux.h
> index c8d487b6..912f36c1 100644
> --- a/lib/igt_aux.h
> +++ b/lib/igt_aux.h
> @@ -34,9 +34,7 @@
> #include <sys/time.h>
> #include <sys/types.h>
> #include <unistd.h>
> -#ifdef __linux__
imho do not remove this, make it like:
#if defined(__linux__) || defined(__FreeBSD__)
> -# 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
Here you have header for this define above.
> +#endif
>
> /* auxialiary igt helpers from igt_aux.c */
> /* generally useful helpers */
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index e7425326..b4b8877f 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -43,9 +43,7 @@
> #include <unistd.h>
> #include <sys/wait.h>
> #include <sys/types.h>
> -#ifdef __linux__
Same here:
#if defined(__linux__) || defined(__FreeBSD__)
> #include <sys/syscall.h>
> -#endif
> #include <pthread.h>
> #include <sys/utsname.h>
> #include <termios.h>
> @@ -786,6 +784,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
>
> static void oom_adjust_for_doom(void)
> {
> +#ifdef __linux__
> int fd;
> const char always_kill[] = "1000";
>
> @@ -793,7 +792,13 @@ 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);
> -
> +#elif defined(__FreeBSD__)
> + /*
> + * oom_score_adj not present in FreeBSD's linprocfs.
> + * Stop process directly instead.
> + */
> + raise(SIGTERM);
> +#endif
> }
>
> /**
> diff --git a/lib/igt_core.h b/lib/igt_core.h
> index aa98e8ed..cc382497 100644
> --- a/lib/igt_core.h
> +++ b/lib/igt_core.h
> @@ -31,7 +31,11 @@
> #define IGT_CORE_H
>
> #include <assert.h>
> +#ifdef __linux__
> #include <byteswap.h>
> +#elif defined(__FreeBSD__)
> +#include <sys/endian.h>
> +#endif
> #include <setjmp.h>
> #include <stdbool.h>
> #include <stdint.h>
> @@ -43,6 +47,10 @@
> #include <getopt.h>
> #include <unistd.h>
>
> +#ifdef __FreeBSD__
> +#include "igt_freebsd.h"
> +#endif
> +
> #ifndef IGT_LOG_DOMAIN
> #define IGT_LOG_DOMAIN (NULL)
> #endif
> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> index a56688a5..fa1e3b69 100644
> --- a/lib/igt_debugfs.c
> +++ b/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>
> diff --git a/lib/igt_device.c b/lib/igt_device.c
> index fddfba72..49b77122 100644
> --- a/lib/igt_device.c
> +++ b/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/lib/igt_device_scan.c b/lib/igt_device_scan.c
> index eb6b45b8..6a921d52 100644
> --- a/lib/igt_device_scan.c
> +++ b/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/lib/igt_eld.c b/lib/igt_eld.c
> index ef6625df..e05ad6de 100644
> --- a/lib/igt_eld.c
> +++ b/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/lib/igt_frame.c b/lib/igt_frame.c
> index 45523a79..ab74e678 100644
> --- a/lib/igt_frame.c
> +++ b/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/lib/igt_freebsd.h b/lib/igt_freebsd.h
> new file mode 100644
> index 00000000..de349148
> --- /dev/null
> +++ b/lib/igt_freebsd.h
> @@ -0,0 +1,123 @@
> +/*
> + * SPDX-License-Identifier: MIT
> + *
> + * Copyright (c) 2022, Jake Freeland <jfree@FreeBSD.org>
> + *
Delete below licence text, you already have SPDX above.
> + * 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.
> + */
> +
> +#if !defined(IGT_FREEBSD_H) && defined(__FreeBSD__)
Do not make it complicated, use what other headers have:
#if !defined(IGT_FREEBSD_H)
#if !defined(__FreeBSD__)
#error "This header is only for FreeBSD platform.
#fi
> +#define IGT_FREEBSD_H
> +
> +#include <sys/errno.h>
> +#include <sys/mman.h>
> +#include <sys/mount.h>
> +#include <sys/sched.h>
> +#include <sys/types.h>
> +#include <sys/watchdog.h>
> +
> +#include <pthread.h>
> +#include <setjmp.h>
> +#include <signal.h>
> +#include <unistd.h>
> +
> +/*
> + * Proper substitutions:
> + * The following macros replace Linux-specific functions
> + * and macros with their FreeBSD equivalents.
> + */
> +
> +#define __s32 int32_t
> +#define __u32 uint32_t
> +#define __u64 uint64_t
> +
> +#define sighandler_t sig_t
> +#define ino64_t ino_t
> +
> +#define jmp_buf sigjmp_buf
> +
> +#define PTRACE_TRACEME PT_TRACE_ME
> +#define PTRACE_ATTACH PT_ATTACH
> +#define PTRACE_PEEKDATA PT_READ_D
> +#define PTRACE_POKEDATA PT_WRITE_D
> +#define PTRACE_DETACH PT_DETACH
> +
> +#define I2C_RDWR I2CRDWR
> +#define I2C_M_RD IIC_M_RD
> +#define i2c_msg iic_msg
> +#define i2c_rdwr_ioctl_data iic_rdwr_data
> +
> +#define bswap_32(x) bswap32(x)
> +
> +#define _IOC_TYPE(nr) (((nr) >> 8) & 255)
> +
> +#define SYS_getdents64 SYS_freebsd11_getdents
> +
> +#define mount(src, dest, fstype, flags, data) \
> + mount(fstype, dest, flags, data)
> +
> +/*
> + * Improper substitutions:
> + * The following macros are temporary replacements for functions
> + * and macros that exist on Linux and do not exist on FreeBSD.
> + */
> +
> +#define ETIME ETIMEDOUT
> +
> +#define MAP_POPULATE MAP_PREFAULT_READ
> +
> +#define MADV_HUGEPAGE MADV_SEQUENTIAL
> +#define MADV_DONTFORK MADV_NOSYNC
> +
> +#define WDIOC_KEEPALIVE WDIOCPATPAT
> +
> +#define SCHED_RESET_ON_FORK 0
> +#define SCHED_IDLE SCHED_OTHER
> +
> +#define gettid() getpid()
> +
> +#define pthread_sigqueue(pid, signo, value) \
> + sigqueue(pid, signo, value)
> +
> +#define signalfd(fd, mask, flags) -ENOSYS
> +#define timerfd_create(c, f) -ENOSYS
> +#define timerfd_settime(fd, f, n, o) -ENOSYS
> +
> +/*
> + * Macro conflict resolution.
> + */
> +
> +#undef ALIGN
> +#undef PAGE_SIZE
> +
> +struct signalfd_siginfo {
> + uint32_t ssi_signo;
> + uint32_t ssi_pid;
> +};
> +
> +struct kmod_module {
> + size_t size;
> +};
> +
> +typedef struct {
> + char state;
> +} proc_t;
> +
> +#endif /* IGT_FREEBSD_H */
> diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
> index f98dd29f..6596092b 100644
> --- a/lib/igt_kmod.h
> +++ b/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/lib/igt_kms.c b/lib/igt_kms.c
> index 665594aa..532a3aa8 100644
> --- a/lib/igt_kms.c
> +++ b/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/lib/igt_os.c b/lib/igt_os.c
> index bdd5d933..bb6994e1 100644
> --- a/lib/igt_os.c
> +++ b/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__)
> + 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__)
> + 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/lib/igt_perf.c b/lib/igt_perf.c
> index b743859f..11c91c5f 100644
> --- a/lib/igt_perf.c
> +++ b/lib/igt_perf.c
> @@ -4,8 +4,10 @@
> #include <stdlib.h>
> #include <string.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <sys/sysinfo.h>
> #include <sys/sysmacros.h>
> +#endif
> #include <time.h>
> #include <unistd.h>
>
> diff --git a/lib/igt_perf.h b/lib/igt_perf.h
> index a8328c70..0cd91386 100644
> --- a/lib/igt_perf.h
> +++ b/lib/igt_perf.h
> @@ -27,10 +27,13 @@
>
> #include <stdint.h>
>
> +#ifdef __linux__
> #include <linux/perf_event.h>
> +#endif
>
> #include "igt_gt.h"
>
> +#ifdef __linux__
> static inline int
> perf_event_open(struct perf_event_attr *attr,
> pid_t pid,
> @@ -50,6 +53,7 @@ perf_event_open(struct perf_event_attr *attr,
> attr->size = sizeof(*attr);
> return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);
> }
> +#endif /* __linux__ */
>
> uint64_t igt_perf_type_id(const char *device);
> int igt_perf_open(uint64_t type, uint64_t config);
> diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> index 312288d0..1e6e9ed3 100644
> --- a/lib/igt_pm.c
> +++ b/lib/igt_pm.c
> @@ -33,7 +33,9 @@
> #include <string.h>
> #include <unistd.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <sys/sysmacros.h>
> +#endif
> #include <sys/types.h>
> #include <dirent.h>
>
> diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
> index 9c307694..a913be4c 100644
> --- a/lib/igt_sysfs.c
> +++ b/lib/igt_sysfs.c
> @@ -24,7 +24,9 @@
>
> #include <inttypes.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <sys/sysmacros.h>
> +#endif
> #include <sys/mount.h>
> #include <errno.h>
> #include <stdarg.h>
> diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
> index 892a7f14..d2381944 100644
> --- a/lib/tests/igt_exit_handler.c
> +++ b/lib/tests/igt_exit_handler.c
> @@ -125,5 +125,9 @@ int main(int argc, char **argv)
> internal_assert_wexited(status, IGT_EXIT_SKIP);
>
> status = testfunc(SIG);
> +#ifdef __linux__
> internal_assert_wsignaled(status, SIGTERM);
> +#elif defined(__FreeBSD__)
> + internal_assert(status == 0);
> +#endif
> }
> diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
------------------------ ^
You already put this into separate patch, please delete these.
> index d19d0945..c7193b06 100644
> --- a/lib/tests/igt_fork.c
> +++ b/lib/tests/igt_fork.c
> @@ -109,7 +109,7 @@ __noreturn static void igt_fork_timeout_leak(void)
> __noreturn static void subtest_leak(void)
> {
> pid_t *children =
> - mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
> + mmap(0, 4096, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANON, -1, 0);
> const int num_children = 4096 / sizeof(*children);
>
> igt_subtest_init(fake_argc, fake_argv);
> diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
> index 058f6265..e8183897 100644
> --- a/lib/tests/igt_tests_common.h
> +++ b/lib/tests/igt_tests_common.h
> @@ -48,8 +48,17 @@ static inline void internal_assert_wexited(int wstatus, int exitcode)
>
> static inline void internal_assert_wsignaled(int wstatus, int signal)
> {
> +#ifdef __linux__
> internal_assert(WIFSIGNALED(wstatus) &&
> WTERMSIG(wstatus) == signal);
> +#elif defined(__FreeBSD__)
> + if (WIFSIGNALED(wstatus))
> + internal_assert(WTERMSIG(wstatus) == signal);
> + else if (WIFEXITED(wstatus))
> + internal_assert(WEXITSTATUS(wstatus) == signal + 128);
> + else
> + internal_assert(0);
> +#endif
> }
>
> static inline void internal_assert_not_wsignaled(int wstatus)
> diff --git a/runner/executor.c b/runner/executor.c
> index 964d0063..c54072cf 100644
> --- a/runner/executor.c
> +++ b/runner/executor.c
> @@ -2,7 +2,9 @@
> #include <errno.h>
> #include <fcntl.h>
> #include <glib.h>
> +#ifdef __linux__
> #include <linux/watchdog.h>
> +#endif
> #if HAVE_OPING
> #include <oping.h>
> #endif
> @@ -33,6 +35,10 @@
> #define KMSG_HEADER "[IGT] "
> #define KMSG_WARN 4
>
> +#ifdef __FreeBSD__
> +#include <sys/watchdog.h>
> +#endif
> +
> static struct {
> int *fds;
> size_t num_dogs;
> diff --git a/runner/job_list.c b/runner/job_list.c
> index 520a98da..6bfa7162 100644
> --- a/runner/job_list.c
> +++ b/runner/job_list.c
> @@ -1,7 +1,12 @@
> #include <ctype.h>
> #include <errno.h>
> #include <fcntl.h>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#elif defined(__FreeBSD__)
> +#include <sys/wait.h>
> +#include <limits.h>
> +#endif
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
> index 938fde8f..42fe1657 100644
> --- a/tests/i915/gem_close_race.c
> +++ b/tests/i915/gem_close_race.c
> @@ -61,7 +61,9 @@ static bool has_softpin;
> static uint64_t exec_addr;
> static uint64_t data_addr;
>
> +#ifdef __linux__
> #define sigev_notify_thread_id _sigev_un._tid
> +#endif
This should come from header from include or lib.
>
> static void selfcopy(int fd, uint32_t ctx, uint32_t handle, int loops)
> {
> diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
> index e39b9047..4f05eb18 100644
> --- a/tests/i915/gem_mmap_gtt.c
> +++ b/tests/i915/gem_mmap_gtt.c
> @@ -566,7 +566,7 @@ test_ptrace(int fd)
> for (int i = 0; i < sz / sizeof(long); i++) {
> long ret;
>
> - ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i);
> + ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i, NULL);
Please put this into separate patch.
> igt_assert_eq_u64(ret, CC);
> cpy[i] = ret;
>
> diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
> index 7e8c02d1..fc4245f6 100644
> --- a/tests/i915/gem_mmap_offset.c
> +++ b/tests/i915/gem_mmap_offset.c
> @@ -520,7 +520,7 @@ static void test_ptrace(int i915)
> for (int i = 0; i < SZ / sizeof(long); i++) {
> long ret;
>
> - ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i);
> + ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i, NULL);
Same here.
> igt_assert_eq_u64(ret, CC);
> cpy[i] = ret;
>
> diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c
> index 4c72157c..9bec4c18 100644
> --- a/tests/i915/i915_module_load.c
> +++ b/tests/i915/i915_module_load.c
> @@ -23,7 +23,9 @@
> #include "igt.h"
> #include <dirent.h>
> #include <sys/utsname.h>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#endif
One final note here, adding #ifdef __linux__ is not
the same as:
#if !defined(IGT_FREEBSD_H)
#include <linux/limits.h>
#endif
On the other side, it is more strightforward, so if this
compiles for other platforms/users it can stay.
Regards,
Kamil
> #include <signal.h>
> #include <libgen.h>
> #include <signal.h>
> diff --git a/tests/i915/i915_pm_backlight.c b/tests/i915/i915_pm_backlight.c
> index cafae7f7..c520cf20 100644
> --- a/tests/i915/i915_pm_backlight.c
> +++ b/tests/i915/i915_pm_backlight.c
> @@ -46,6 +46,10 @@ struct context {
> #define FADESTEPS 10
> #define FADESPEED 100 /* milliseconds between steps */
>
> +#ifdef __FreeBSD__
> +#include <libgen.h>
> +#endif
> +
> IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
>
> static int backlight_read(int *result, const char *fname)
> diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
> index e95875dc..761e76f9 100644
> --- a/tests/i915/i915_pm_rpm.c
> +++ b/tests/i915/i915_pm_rpm.c
> @@ -40,8 +40,10 @@
> #include <sys/mman.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <linux/i2c.h>
> #include <linux/i2c-dev.h>
> +#endif
>
> #include <drm.h>
>
> @@ -54,6 +56,12 @@
> #include "igt_device.h"
> #include "igt_edid.h"
>
> +#ifdef __FreeBSD__
> +#include <limits.h>
> +#include <dev/iicbus/iic.h>
> +#define addr slave
> +#endif
> +
> #define MSR_PC8_RES 0x630
> #define MSR_PC9_RES 0x631
> #define MSR_PC10_RES 0x632
> diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
> index 3041f1cd..e0e5af78 100644
> --- a/tests/kms_content_protection.c
> +++ b/tests/kms_content_protection.c
> @@ -24,7 +24,9 @@
>
> #include <poll.h>
> #include <fcntl.h>
> +#ifdef __linux__
> #include <sys/epoll.h>
> +#endif
> #include <sys/stat.h>
> #include <libudev.h>
> #include "igt.h"
> diff --git a/tests/kms_flip.c b/tests/kms_flip.c
> index 0567edea..1127e418 100755
> --- a/tests/kms_flip.c
> +++ b/tests/kms_flip.c
> @@ -45,6 +45,10 @@
> #include "i915/gem_create.h"
> #include "igt_stats.h"
>
> +#ifdef __FreeBSD__
> +#include <sys/consio.h>
> +#endif
> +
> #define TEST_DPMS (1 << 0)
>
> #define TEST_PAN (1 << 3)
> diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
> index 77521108..cd980c6a 100644
> --- a/tests/kms_sysfs_edid_timing.c
> +++ b/tests/kms_sysfs_edid_timing.c
> @@ -26,6 +26,10 @@
> #include <fcntl.h>
> #include <sys/stat.h>
>
> +#ifdef __FreeBSD__
> +#include <limits.h>
> +#endif
> +
> #define THRESHOLD_PER_CONNECTOR 150
> #define THRESHOLD_PER_CONNECTOR_MEAN 140
> #define THRESHOLD_ALL_CONNECTORS_MEAN 100
> diff --git a/tests/tools_test.c b/tests/tools_test.c
> index 237f0433..89a19d11 100644
> --- a/tests/tools_test.c
> +++ b/tests/tools_test.c
> @@ -28,7 +28,11 @@
> #include <fcntl.h>
> #include <libgen.h>
> #include <unistd.h>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#elif defined(__FreeBSD__)
> +#include <limits.h>
> +#endif
>
> #define TOOLS "../tools/"
>
> diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c
> index ad5ee6a6..3e53c6d9 100644
> --- a/tools/intel_gvtg_test.c
> +++ b/tools/intel_gvtg_test.c
> @@ -55,6 +55,10 @@
> #include <limits.h>
> #include <dirent.h>
>
> +#ifdef __FreeBSD__
> +#include <sys/wait.h>
> +#endif
> +
> #define RANDOM(x) (rand() % x)
>
>
> --
> 2.37.0 (Apple Git-136)
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility
2022-10-06 7:59 ` [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility Petri Latvala
@ 2022-10-06 15:49 ` Jake Freeland
0 siblings, 0 replies; 20+ messages in thread
From: Jake Freeland @ 2022-10-06 15:49 UTC (permalink / raw)
To: Petri Latvala; +Cc: igt-dev, Jake Freeland
[-- Attachment #1: Type: text/plain, Size: 27161 bytes --]
Petri,
Yes. The igt self-checks halt on FreeBSD if the oom_adjust_for_doom()
process does not eventually exit. The FreeBSD scheduler will not kill that
process because the process's score has not been set. Forcing the process
to terminate is not a permanent solution; it is not elegant or correct.
Instead,
it simply eliminates this halt.
Now that I think about it, I can probably just temporarily patch this in on
the
FreeBSD side instead of upstreaming it
Thank you,
Jake Freeland
On Thu, Oct 6, 2022 at 3:00 AM Petri Latvala <petri.latvala@intel.com>
wrote:
> On Wed, Oct 05, 2022 at 09:23:29PM -0500, Jake Freeland wrote:
> > FreeBSD's Linux compatbility layer, LinuxKPI, has introduced
> > modern drm drivers to the FreeBSD desktop. With drm drivers,
> > comes the need for drm testing. This patch allows a portion
> > of igt-gpu-tools to compile on FreeBSD
> >
> > Signed-off-by: Jake Freeland <jfree@freebsd.org>
> > ---
> > benchmarks/gem_exec_tracer.c | 4 ++
> > benchmarks/gem_syslatency.c | 6 ++
> > include/linux-uapi/sync_file.h | 5 ++
> > lib/i915/intel_memory_region.c | 4 ++
> > lib/i915/perf.c | 2 +
> > lib/igt_audio.c | 4 ++
> > lib/igt_aux.c | 2 +
> > lib/igt_aux.h | 6 +-
> > lib/igt_core.c | 11 ++-
> > lib/igt_core.h | 8 +++
> > lib/igt_debugfs.c | 2 +
> > lib/igt_device.c | 2 +
> > lib/igt_device_scan.c | 4 ++
> > lib/igt_eld.c | 4 ++
> > lib/igt_frame.c | 4 ++
> > lib/igt_freebsd.h | 123 +++++++++++++++++++++++++++++++++
> > lib/igt_kmod.h | 2 +
> > lib/igt_kms.c | 4 ++
> > lib/igt_os.c | 19 +++++
> > lib/igt_perf.c | 2 +
> > lib/igt_perf.h | 4 ++
> > lib/igt_pm.c | 2 +
> > lib/igt_sysfs.c | 2 +
> > lib/tests/igt_exit_handler.c | 4 ++
> > lib/tests/igt_fork.c | 2 +-
> > lib/tests/igt_tests_common.h | 9 +++
> > runner/executor.c | 6 ++
> > runner/job_list.c | 5 ++
> > tests/i915/gem_close_race.c | 2 +
> > tests/i915/gem_mmap_gtt.c | 2 +-
> > tests/i915/gem_mmap_offset.c | 2 +-
> > tests/i915/i915_module_load.c | 2 +
> > tests/i915/i915_pm_backlight.c | 4 ++
> > tests/i915/i915_pm_rpm.c | 8 +++
> > tests/kms_content_protection.c | 2 +
> > tests/kms_flip.c | 4 ++
> > tests/kms_sysfs_edid_timing.c | 4 ++
> > tests/tools_test.c | 4 ++
> > tools/intel_gvtg_test.c | 4 ++
> > 39 files changed, 280 insertions(+), 10 deletions(-)
> > create mode 100644 lib/igt_freebsd.h
> >
> > diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
> > index e6973991..7e86473e 100644
> > --- a/benchmarks/gem_exec_tracer.c
> > +++ b/benchmarks/gem_exec_tracer.c
> > @@ -41,6 +41,10 @@
> > #include "intel_aub.h"
> > #include "intel_chipset.h"
> >
> > +#ifdef __FreeBSD__
> > +#include "igt_freebsd.h"
> > +#endif
> > +
> > static int (*libc_close)(int fd);
> > static int (*libc_ioctl)(int fd, unsigned long request, void *argp);
> >
> > diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
> > index 035ee934..dafc6ac0 100644
> > --- a/benchmarks/gem_syslatency.c
> > +++ b/benchmarks/gem_syslatency.c
> > @@ -42,12 +42,18 @@
> > #include <limits.h>
> > #include "drm.h"
> >
> > +#ifdef __linux__
> > #include <linux/unistd.h>
> > +#elif defined(__FreeBSD__)
> > +#include "igt_freebsd.h"
> > +#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/include/linux-uapi/sync_file.h
> b/include/linux-uapi/sync_file.h
> > index b4f2db00..270c1cbc 100644
> > --- a/include/linux-uapi/sync_file.h
> > +++ b/include/linux-uapi/sync_file.h
> > @@ -12,8 +12,13 @@
> > #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 "igt_freebsd.h"
> > +#endif
> >
> > /**
> > * struct sync_merge_data - data passed to merge ioctl
> > diff --git a/lib/i915/intel_memory_region.c
> b/lib/i915/intel_memory_region.c
> > index 568bace9..0a59f290 100644
> > --- a/lib/i915/intel_memory_region.c
> > +++ b/lib/i915/intel_memory_region.c
> > @@ -21,7 +21,11 @@
> > * IN THE SOFTWARE.
> > */
> >
> > +#ifdef __linux__
> > #include <linux/limits.h>
> > +#elif defined(__FreeBSD__)
> > +#include <limits.h>
> > +#endif
> > #include <signal.h>
> > #include <sys/ioctl.h>
> > #include <sys/time.h>
> > diff --git a/lib/i915/perf.c b/lib/i915/perf.c
> > index d88835ff..beda6b8a 100644
> > --- a/lib/i915/perf.c
> > +++ b/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/lib/igt_audio.c b/lib/igt_audio.c
> > index e0b1bafe..201a39c6 100644
> > --- a/lib/igt_audio.c
> > +++ b/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/lib/igt_aux.c b/lib/igt_aux.c
> > index edb53425..d7e2714f 100644
> > --- a/lib/igt_aux.c
> > +++ b/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"
> > diff --git a/lib/igt_aux.h b/lib/igt_aux.h
> > index c8d487b6..912f36c1 100644
> > --- a/lib/igt_aux.h
> > +++ b/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/lib/igt_core.c b/lib/igt_core.c
> > index e7425326..b4b8877f 100644
> > --- a/lib/igt_core.c
> > +++ b/lib/igt_core.c
> > @@ -43,9 +43,7 @@
> > #include <unistd.h>
> > #include <sys/wait.h>
> > #include <sys/types.h>
> > -#ifdef __linux__
> > #include <sys/syscall.h>
> > -#endif
> > #include <pthread.h>
> > #include <sys/utsname.h>
> > #include <termios.h>
> > @@ -786,6 +784,7 @@ static void print_usage(const char *help_str, bool
> output_on_stderr)
> >
> > static void oom_adjust_for_doom(void)
> > {
> > +#ifdef __linux__
> > int fd;
> > const char always_kill[] = "1000";
> >
> > @@ -793,7 +792,13 @@ 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);
> > -
> > +#elif defined(__FreeBSD__)
> > + /*
> > + * oom_score_adj not present in FreeBSD's linprocfs.
> > + * Stop process directly instead.
> > + */
> > + raise(SIGTERM);
> > +#endif
>
> You have a misunderstanding here. oom_adjust_for_doom() doesn't make
> the process die _now_. It gives the kernel a hint that _if_
> out-of-memory hits, "I volunteer as tribute".
>
>
> --
> Petri Latvala
>
>
>
> > }
> >
> > /**
> > diff --git a/lib/igt_core.h b/lib/igt_core.h
> > index aa98e8ed..cc382497 100644
> > --- a/lib/igt_core.h
> > +++ b/lib/igt_core.h
> > @@ -31,7 +31,11 @@
> > #define IGT_CORE_H
> >
> > #include <assert.h>
> > +#ifdef __linux__
> > #include <byteswap.h>
> > +#elif defined(__FreeBSD__)
> > +#include <sys/endian.h>
> > +#endif
> > #include <setjmp.h>
> > #include <stdbool.h>
> > #include <stdint.h>
> > @@ -43,6 +47,10 @@
> > #include <getopt.h>
> > #include <unistd.h>
> >
> > +#ifdef __FreeBSD__
> > +#include "igt_freebsd.h"
> > +#endif
> > +
> > #ifndef IGT_LOG_DOMAIN
> > #define IGT_LOG_DOMAIN (NULL)
> > #endif
> > diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> > index a56688a5..fa1e3b69 100644
> > --- a/lib/igt_debugfs.c
> > +++ b/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>
> > diff --git a/lib/igt_device.c b/lib/igt_device.c
> > index fddfba72..49b77122 100644
> > --- a/lib/igt_device.c
> > +++ b/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/lib/igt_device_scan.c b/lib/igt_device_scan.c
> > index eb6b45b8..6a921d52 100644
> > --- a/lib/igt_device_scan.c
> > +++ b/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/lib/igt_eld.c b/lib/igt_eld.c
> > index ef6625df..e05ad6de 100644
> > --- a/lib/igt_eld.c
> > +++ b/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/lib/igt_frame.c b/lib/igt_frame.c
> > index 45523a79..ab74e678 100644
> > --- a/lib/igt_frame.c
> > +++ b/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/lib/igt_freebsd.h b/lib/igt_freebsd.h
> > new file mode 100644
> > index 00000000..de349148
> > --- /dev/null
> > +++ b/lib/igt_freebsd.h
> > @@ -0,0 +1,123 @@
> > +/*
> > + * SPDX-License-Identifier: MIT
> > + *
> > + * Copyright (c) 2022, Jake Freeland <jfree@FreeBSD.org>
> > + *
> > + * 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.
> > + */
> > +
> > +#if !defined(IGT_FREEBSD_H) && defined(__FreeBSD__)
> > +#define IGT_FREEBSD_H
> > +
> > +#include <sys/errno.h>
> > +#include <sys/mman.h>
> > +#include <sys/mount.h>
> > +#include <sys/sched.h>
> > +#include <sys/types.h>
> > +#include <sys/watchdog.h>
> > +
> > +#include <pthread.h>
> > +#include <setjmp.h>
> > +#include <signal.h>
> > +#include <unistd.h>
> > +
> > +/*
> > + * Proper substitutions:
> > + * The following macros replace Linux-specific functions
> > + * and macros with their FreeBSD equivalents.
> > + */
> > +
> > +#define __s32 int32_t
> > +#define __u32 uint32_t
> > +#define __u64 uint64_t
> > +
> > +#define sighandler_t sig_t
> > +#define ino64_t ino_t
> > +
> > +#define jmp_buf sigjmp_buf
> > +
> > +#define PTRACE_TRACEME PT_TRACE_ME
> > +#define PTRACE_ATTACH PT_ATTACH
> > +#define PTRACE_PEEKDATA PT_READ_D
> > +#define PTRACE_POKEDATA PT_WRITE_D
> > +#define PTRACE_DETACH PT_DETACH
> > +
> > +#define I2C_RDWR I2CRDWR
> > +#define I2C_M_RD IIC_M_RD
> > +#define i2c_msg iic_msg
> > +#define i2c_rdwr_ioctl_data iic_rdwr_data
> > +
> > +#define bswap_32(x) bswap32(x)
> > +
> > +#define _IOC_TYPE(nr) (((nr) >> 8) & 255)
> > +
> > +#define SYS_getdents64 SYS_freebsd11_getdents
> > +
> > +#define mount(src, dest, fstype, flags, data) \
> > + mount(fstype, dest, flags, data)
> > +
> > +/*
> > + * Improper substitutions:
> > + * The following macros are temporary replacements for functions
> > + * and macros that exist on Linux and do not exist on FreeBSD.
> > + */
> > +
> > +#define ETIME ETIMEDOUT
> > +
> > +#define MAP_POPULATE MAP_PREFAULT_READ
> > +
> > +#define MADV_HUGEPAGE MADV_SEQUENTIAL
> > +#define MADV_DONTFORK MADV_NOSYNC
> > +
> > +#define WDIOC_KEEPALIVE WDIOCPATPAT
> > +
> > +#define SCHED_RESET_ON_FORK 0
> > +#define SCHED_IDLE SCHED_OTHER
> > +
> > +#define gettid() getpid()
> > +
> > +#define pthread_sigqueue(pid, signo, value) \
> > + sigqueue(pid, signo, value)
> > +
> > +#define signalfd(fd, mask, flags) -ENOSYS
> > +#define timerfd_create(c, f) -ENOSYS
> > +#define timerfd_settime(fd, f, n, o) -ENOSYS
> > +
> > +/*
> > + * Macro conflict resolution.
> > + */
> > +
> > +#undef ALIGN
> > +#undef PAGE_SIZE
> > +
> > +struct signalfd_siginfo {
> > + uint32_t ssi_signo;
> > + uint32_t ssi_pid;
> > +};
> > +
> > +struct kmod_module {
> > + size_t size;
> > +};
> > +
> > +typedef struct {
> > + char state;
> > +} proc_t;
> > +
> > +#endif /* IGT_FREEBSD_H */
> > diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
> > index f98dd29f..6596092b 100644
> > --- a/lib/igt_kmod.h
> > +++ b/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/lib/igt_kms.c b/lib/igt_kms.c
> > index 665594aa..532a3aa8 100644
> > --- a/lib/igt_kms.c
> > +++ b/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/lib/igt_os.c b/lib/igt_os.c
> > index bdd5d933..bb6994e1 100644
> > --- a/lib/igt_os.c
> > +++ b/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__)
> > + 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__)
> > + 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/lib/igt_perf.c b/lib/igt_perf.c
> > index b743859f..11c91c5f 100644
> > --- a/lib/igt_perf.c
> > +++ b/lib/igt_perf.c
> > @@ -4,8 +4,10 @@
> > #include <stdlib.h>
> > #include <string.h>
> > #include <sys/stat.h>
> > +#ifdef __linux__
> > #include <sys/sysinfo.h>
> > #include <sys/sysmacros.h>
> > +#endif
> > #include <time.h>
> > #include <unistd.h>
> >
> > diff --git a/lib/igt_perf.h b/lib/igt_perf.h
> > index a8328c70..0cd91386 100644
> > --- a/lib/igt_perf.h
> > +++ b/lib/igt_perf.h
> > @@ -27,10 +27,13 @@
> >
> > #include <stdint.h>
> >
> > +#ifdef __linux__
> > #include <linux/perf_event.h>
> > +#endif
> >
> > #include "igt_gt.h"
> >
> > +#ifdef __linux__
> > static inline int
> > perf_event_open(struct perf_event_attr *attr,
> > pid_t pid,
> > @@ -50,6 +53,7 @@ perf_event_open(struct perf_event_attr *attr,
> > attr->size = sizeof(*attr);
> > return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd,
> flags);
> > }
> > +#endif /* __linux__ */
> >
> > uint64_t igt_perf_type_id(const char *device);
> > int igt_perf_open(uint64_t type, uint64_t config);
> > diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> > index 312288d0..1e6e9ed3 100644
> > --- a/lib/igt_pm.c
> > +++ b/lib/igt_pm.c
> > @@ -33,7 +33,9 @@
> > #include <string.h>
> > #include <unistd.h>
> > #include <sys/stat.h>
> > +#ifdef __linux__
> > #include <sys/sysmacros.h>
> > +#endif
> > #include <sys/types.h>
> > #include <dirent.h>
> >
> > diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
> > index 9c307694..a913be4c 100644
> > --- a/lib/igt_sysfs.c
> > +++ b/lib/igt_sysfs.c
> > @@ -24,7 +24,9 @@
> >
> > #include <inttypes.h>
> > #include <sys/stat.h>
> > +#ifdef __linux__
> > #include <sys/sysmacros.h>
> > +#endif
> > #include <sys/mount.h>
> > #include <errno.h>
> > #include <stdarg.h>
> > diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
> > index 892a7f14..d2381944 100644
> > --- a/lib/tests/igt_exit_handler.c
> > +++ b/lib/tests/igt_exit_handler.c
> > @@ -125,5 +125,9 @@ int main(int argc, char **argv)
> > internal_assert_wexited(status, IGT_EXIT_SKIP);
> >
> > status = testfunc(SIG);
> > +#ifdef __linux__
> > internal_assert_wsignaled(status, SIGTERM);
> > +#elif defined(__FreeBSD__)
> > + internal_assert(status == 0);
> > +#endif
> > }
> > diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
> > index d19d0945..c7193b06 100644
> > --- a/lib/tests/igt_fork.c
> > +++ b/lib/tests/igt_fork.c
> > @@ -109,7 +109,7 @@ __noreturn static void igt_fork_timeout_leak(void)
> > __noreturn static void subtest_leak(void)
> > {
> > pid_t *children =
> > - mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
> > + mmap(0, 4096, PROT_WRITE | PROT_READ, MAP_SHARED |
> MAP_ANON, -1, 0);
> > const int num_children = 4096 / sizeof(*children);
> >
> > igt_subtest_init(fake_argc, fake_argv);
> > diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
> > index 058f6265..e8183897 100644
> > --- a/lib/tests/igt_tests_common.h
> > +++ b/lib/tests/igt_tests_common.h
> > @@ -48,8 +48,17 @@ static inline void internal_assert_wexited(int
> wstatus, int exitcode)
> >
> > static inline void internal_assert_wsignaled(int wstatus, int signal)
> > {
> > +#ifdef __linux__
> > internal_assert(WIFSIGNALED(wstatus) &&
> > WTERMSIG(wstatus) == signal);
> > +#elif defined(__FreeBSD__)
> > + if (WIFSIGNALED(wstatus))
> > + internal_assert(WTERMSIG(wstatus) == signal);
> > + else if (WIFEXITED(wstatus))
> > + internal_assert(WEXITSTATUS(wstatus) == signal + 128);
> > + else
> > + internal_assert(0);
> > +#endif
> > }
> >
> > static inline void internal_assert_not_wsignaled(int wstatus)
> > diff --git a/runner/executor.c b/runner/executor.c
> > index 964d0063..c54072cf 100644
> > --- a/runner/executor.c
> > +++ b/runner/executor.c
> > @@ -2,7 +2,9 @@
> > #include <errno.h>
> > #include <fcntl.h>
> > #include <glib.h>
> > +#ifdef __linux__
> > #include <linux/watchdog.h>
> > +#endif
> > #if HAVE_OPING
> > #include <oping.h>
> > #endif
> > @@ -33,6 +35,10 @@
> > #define KMSG_HEADER "[IGT] "
> > #define KMSG_WARN 4
> >
> > +#ifdef __FreeBSD__
> > +#include <sys/watchdog.h>
> > +#endif
> > +
> > static struct {
> > int *fds;
> > size_t num_dogs;
> > diff --git a/runner/job_list.c b/runner/job_list.c
> > index 520a98da..6bfa7162 100644
> > --- a/runner/job_list.c
> > +++ b/runner/job_list.c
> > @@ -1,7 +1,12 @@
> > #include <ctype.h>
> > #include <errno.h>
> > #include <fcntl.h>
> > +#ifdef __linux__
> > #include <linux/limits.h>
> > +#elif defined(__FreeBSD__)
> > +#include <sys/wait.h>
> > +#include <limits.h>
> > +#endif
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <string.h>
> > diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
> > index 938fde8f..42fe1657 100644
> > --- a/tests/i915/gem_close_race.c
> > +++ b/tests/i915/gem_close_race.c
> > @@ -61,7 +61,9 @@ static bool has_softpin;
> > static uint64_t exec_addr;
> > static uint64_t data_addr;
> >
> > +#ifdef __linux__
> > #define sigev_notify_thread_id _sigev_un._tid
> > +#endif
> >
> > static void selfcopy(int fd, uint32_t ctx, uint32_t handle, int loops)
> > {
> > diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
> > index e39b9047..4f05eb18 100644
> > --- a/tests/i915/gem_mmap_gtt.c
> > +++ b/tests/i915/gem_mmap_gtt.c
> > @@ -566,7 +566,7 @@ test_ptrace(int fd)
> > for (int i = 0; i < sz / sizeof(long); i++) {
> > long ret;
> >
> > - ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i);
> > + ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i, NULL);
> > igt_assert_eq_u64(ret, CC);
> > cpy[i] = ret;
> >
> > diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
> > index 7e8c02d1..fc4245f6 100644
> > --- a/tests/i915/gem_mmap_offset.c
> > +++ b/tests/i915/gem_mmap_offset.c
> > @@ -520,7 +520,7 @@ static void test_ptrace(int i915)
> > for (int i = 0; i < SZ / sizeof(long);
> i++) {
> > long ret;
> >
> > - ret = ptrace(PTRACE_PEEKDATA, pid,
> ptr + i);
> > + ret = ptrace(PTRACE_PEEKDATA, pid,
> ptr + i, NULL);
> > igt_assert_eq_u64(ret, CC);
> > cpy[i] = ret;
> >
> > diff --git a/tests/i915/i915_module_load.c
> b/tests/i915/i915_module_load.c
> > index 4c72157c..9bec4c18 100644
> > --- a/tests/i915/i915_module_load.c
> > +++ b/tests/i915/i915_module_load.c
> > @@ -23,7 +23,9 @@
> > #include "igt.h"
> > #include <dirent.h>
> > #include <sys/utsname.h>
> > +#ifdef __linux__
> > #include <linux/limits.h>
> > +#endif
> > #include <signal.h>
> > #include <libgen.h>
> > #include <signal.h>
> > diff --git a/tests/i915/i915_pm_backlight.c
> b/tests/i915/i915_pm_backlight.c
> > index cafae7f7..c520cf20 100644
> > --- a/tests/i915/i915_pm_backlight.c
> > +++ b/tests/i915/i915_pm_backlight.c
> > @@ -46,6 +46,10 @@ struct context {
> > #define FADESTEPS 10
> > #define FADESPEED 100 /* milliseconds between steps */
> >
> > +#ifdef __FreeBSD__
> > +#include <libgen.h>
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
> >
> > static int backlight_read(int *result, const char *fname)
> > diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
> > index e95875dc..761e76f9 100644
> > --- a/tests/i915/i915_pm_rpm.c
> > +++ b/tests/i915/i915_pm_rpm.c
> > @@ -40,8 +40,10 @@
> > #include <sys/mman.h>
> > #include <sys/types.h>
> > #include <sys/stat.h>
> > +#ifdef __linux__
> > #include <linux/i2c.h>
> > #include <linux/i2c-dev.h>
> > +#endif
> >
> > #include <drm.h>
> >
> > @@ -54,6 +56,12 @@
> > #include "igt_device.h"
> > #include "igt_edid.h"
> >
> > +#ifdef __FreeBSD__
> > +#include <limits.h>
> > +#include <dev/iicbus/iic.h>
> > +#define addr slave
> > +#endif
> > +
> > #define MSR_PC8_RES 0x630
> > #define MSR_PC9_RES 0x631
> > #define MSR_PC10_RES 0x632
> > diff --git a/tests/kms_content_protection.c
> b/tests/kms_content_protection.c
> > index 3041f1cd..e0e5af78 100644
> > --- a/tests/kms_content_protection.c
> > +++ b/tests/kms_content_protection.c
> > @@ -24,7 +24,9 @@
> >
> > #include <poll.h>
> > #include <fcntl.h>
> > +#ifdef __linux__
> > #include <sys/epoll.h>
> > +#endif
> > #include <sys/stat.h>
> > #include <libudev.h>
> > #include "igt.h"
> > diff --git a/tests/kms_flip.c b/tests/kms_flip.c
> > index 0567edea..1127e418 100755
> > --- a/tests/kms_flip.c
> > +++ b/tests/kms_flip.c
> > @@ -45,6 +45,10 @@
> > #include "i915/gem_create.h"
> > #include "igt_stats.h"
> >
> > +#ifdef __FreeBSD__
> > +#include <sys/consio.h>
> > +#endif
> > +
> > #define TEST_DPMS (1 << 0)
> >
> > #define TEST_PAN (1 << 3)
> > diff --git a/tests/kms_sysfs_edid_timing.c
> b/tests/kms_sysfs_edid_timing.c
> > index 77521108..cd980c6a 100644
> > --- a/tests/kms_sysfs_edid_timing.c
> > +++ b/tests/kms_sysfs_edid_timing.c
> > @@ -26,6 +26,10 @@
> > #include <fcntl.h>
> > #include <sys/stat.h>
> >
> > +#ifdef __FreeBSD__
> > +#include <limits.h>
> > +#endif
> > +
> > #define THRESHOLD_PER_CONNECTOR 150
> > #define THRESHOLD_PER_CONNECTOR_MEAN 140
> > #define THRESHOLD_ALL_CONNECTORS_MEAN 100
> > diff --git a/tests/tools_test.c b/tests/tools_test.c
> > index 237f0433..89a19d11 100644
> > --- a/tests/tools_test.c
> > +++ b/tests/tools_test.c
> > @@ -28,7 +28,11 @@
> > #include <fcntl.h>
> > #include <libgen.h>
> > #include <unistd.h>
> > +#ifdef __linux__
> > #include <linux/limits.h>
> > +#elif defined(__FreeBSD__)
> > +#include <limits.h>
> > +#endif
> >
> > #define TOOLS "../tools/"
> >
> > diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c
> > index ad5ee6a6..3e53c6d9 100644
> > --- a/tools/intel_gvtg_test.c
> > +++ b/tools/intel_gvtg_test.c
> > @@ -55,6 +55,10 @@
> > #include <limits.h>
> > #include <dirent.h>
> >
> > +#ifdef __FreeBSD__
> > +#include <sys/wait.h>
> > +#endif
> > +
> > #define RANDOM(x) (rand() % x)
> >
> >
> > --
> > 2.37.0 (Apple Git-136)
> >
>
[-- Attachment #2: Type: text/html, Size: 35691 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* [igt-dev] ✗ Fi.CI.IGT: failure for Introduced partial FreeBSD compatibility (rev8)
2022-10-06 2:23 [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility Jake Freeland
` (2 preceding siblings ...)
2022-10-06 12:50 ` Kamil Konieczny
@ 2022-10-06 17:25 ` Patchwork
3 siblings, 0 replies; 20+ messages in thread
From: Patchwork @ 2022-10-06 17:25 UTC (permalink / raw)
To: Jake Freeland; +Cc: igt-dev
[-- Attachment #1: Type: text/plain, Size: 49557 bytes --]
== Series Details ==
Series: Introduced partial FreeBSD compatibility (rev8)
URL : https://patchwork.freedesktop.org/series/108081/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_12221_full -> IGTPW_7917_full
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with IGTPW_7917_full absolutely need to be
verified manually.
If you think the reported changes have nothing to do with the changes
introduced in IGTPW_7917_full, please notify your bug team to allow them
to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/index.html
Participating hosts (9 -> 9)
------------------------------
Additional (3): shard-rkl shard-dg1 shard-tglu
Missing (3): pig-skl-6260u pig-kbl-iris pig-glk-j5005
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in IGTPW_7917_full:
### IGT changes ###
#### Possible regressions ####
* igt@kms_plane@plane-position-hole-dpms@pipe-a-planes:
- shard-tglb: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-tglb2/igt@kms_plane@plane-position-hole-dpms@pipe-a-planes.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb8/igt@kms_plane@plane-position-hole-dpms@pipe-a-planes.html
New tests
---------
New tests have been introduced between CI_DRM_12221_full and IGTPW_7917_full:
### New IGT tests (1) ###
* igt@kms_color@gamma@pipe-b-hdmi-a-3:
- Statuses : 1 pass(s)
- Exec time: [0.42] s
Known issues
------------
Here are the changes found in IGTPW_7917_full that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_ctx_persistence@smoketest:
- shard-snb: NOTRUN -> [SKIP][3] ([fdo#109271] / [i915#1099]) +1 similar issue
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-snb7/igt@gem_ctx_persistence@smoketest.html
* igt@gem_eio@reset-stress:
- shard-tglb: [PASS][4] -> [FAIL][5] ([i915#5784])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-tglb7/igt@gem_eio@reset-stress.html
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb2/igt@gem_eio@reset-stress.html
* igt@gem_exec_balancer@parallel-balancer:
- shard-iclb: NOTRUN -> [SKIP][6] ([i915#4525])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb5/igt@gem_exec_balancer@parallel-balancer.html
* igt@gem_exec_balancer@parallel-bb-first:
- shard-iclb: [PASS][7] -> [SKIP][8] ([i915#4525])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-iclb2/igt@gem_exec_balancer@parallel-bb-first.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb8/igt@gem_exec_balancer@parallel-bb-first.html
* igt@gem_exec_fair@basic-deadline:
- shard-apl: NOTRUN -> [FAIL][9] ([i915#2846])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-apl6/igt@gem_exec_fair@basic-deadline.html
- shard-glk: NOTRUN -> [FAIL][10] ([i915#2846])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-glk7/igt@gem_exec_fair@basic-deadline.html
* igt@gem_exec_fair@basic-pace@vcs0:
- shard-iclb: [PASS][11] -> [FAIL][12] ([i915#2842])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-iclb8/igt@gem_exec_fair@basic-pace@vcs0.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb1/igt@gem_exec_fair@basic-pace@vcs0.html
* igt@gem_huc_copy@huc-copy:
- shard-tglb: [PASS][13] -> [SKIP][14] ([i915#2190])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-tglb2/igt@gem_huc_copy@huc-copy.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb7/igt@gem_huc_copy@huc-copy.html
* igt@gem_lmem_swapping@basic:
- shard-iclb: NOTRUN -> [SKIP][15] ([i915#4613]) +1 similar issue
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb7/igt@gem_lmem_swapping@basic.html
- shard-apl: NOTRUN -> [SKIP][16] ([fdo#109271] / [i915#4613]) +1 similar issue
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-apl2/igt@gem_lmem_swapping@basic.html
- shard-tglb: NOTRUN -> [SKIP][17] ([i915#4613]) +1 similar issue
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb5/igt@gem_lmem_swapping@basic.html
* igt@gem_lmem_swapping@massive-random:
- shard-glk: NOTRUN -> [SKIP][18] ([fdo#109271] / [i915#4613]) +2 similar issues
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-glk7/igt@gem_lmem_swapping@massive-random.html
* igt@gem_pread@exhaustion:
- shard-apl: NOTRUN -> [WARN][19] ([i915#2658])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-apl7/igt@gem_pread@exhaustion.html
* igt@gem_pxp@dmabuf-shared-protected-dst-is-context-refcounted:
- shard-iclb: NOTRUN -> [SKIP][20] ([i915#4270]) +1 similar issue
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb4/igt@gem_pxp@dmabuf-shared-protected-dst-is-context-refcounted.html
- shard-tglb: NOTRUN -> [SKIP][21] ([i915#4270]) +1 similar issue
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb8/igt@gem_pxp@dmabuf-shared-protected-dst-is-context-refcounted.html
* igt@gem_render_copy@y-tiled-to-vebox-linear:
- shard-iclb: NOTRUN -> [SKIP][22] ([i915#768]) +1 similar issue
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb6/igt@gem_render_copy@y-tiled-to-vebox-linear.html
* igt@gem_userptr_blits@vma-merge:
- shard-glk: NOTRUN -> [FAIL][23] ([i915#3318])
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-glk5/igt@gem_userptr_blits@vma-merge.html
* igt@gen7_exec_parse@cmd-crossing-page:
- shard-iclb: NOTRUN -> [SKIP][24] ([fdo#109289]) +3 similar issues
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb1/igt@gen7_exec_parse@cmd-crossing-page.html
* igt@gen9_exec_parse@allowed-single:
- shard-apl: [PASS][25] -> [DMESG-WARN][26] ([i915#5566] / [i915#716])
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-apl1/igt@gen9_exec_parse@allowed-single.html
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-apl7/igt@gen9_exec_parse@allowed-single.html
* igt@gen9_exec_parse@bb-start-cmd:
- shard-tglb: NOTRUN -> [SKIP][27] ([i915#2527] / [i915#2856])
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb5/igt@gen9_exec_parse@bb-start-cmd.html
- shard-iclb: NOTRUN -> [SKIP][28] ([i915#2856])
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb8/igt@gen9_exec_parse@bb-start-cmd.html
* igt@i915_module_load@reload-with-fault-injection:
- shard-snb: [PASS][29] -> [DMESG-WARN][30] ([i915#4528])
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-snb5/igt@i915_module_load@reload-with-fault-injection.html
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-snb4/igt@i915_module_load@reload-with-fault-injection.html
* igt@i915_pm_dc@dc9-dpms:
- shard-apl: [PASS][31] -> [SKIP][32] ([fdo#109271])
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-apl3/igt@i915_pm_dc@dc9-dpms.html
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-apl1/igt@i915_pm_dc@dc9-dpms.html
* igt@i915_pm_lpsp@screens-disabled:
- shard-tglb: NOTRUN -> [SKIP][33] ([i915#1902])
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb3/igt@i915_pm_lpsp@screens-disabled.html
- shard-iclb: NOTRUN -> [SKIP][34] ([i915#1902])
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb7/igt@i915_pm_lpsp@screens-disabled.html
* igt@i915_pm_rc6_residency@media-rc6-accuracy:
- shard-tglb: NOTRUN -> [SKIP][35] ([fdo#109289]) +3 similar issues
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb5/igt@i915_pm_rc6_residency@media-rc6-accuracy.html
* igt@i915_selftest@live@gt_pm:
- shard-tglb: NOTRUN -> [DMESG-FAIL][36] ([i915#1759])
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb8/igt@i915_selftest@live@gt_pm.html
* igt@kms_async_flips@alternate-sync-async-flip@pipe-d-edp-1:
- shard-tglb: [PASS][37] -> [FAIL][38] ([i915#2521])
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-tglb3/igt@kms_async_flips@alternate-sync-async-flip@pipe-d-edp-1.html
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb2/igt@kms_async_flips@alternate-sync-async-flip@pipe-d-edp-1.html
* igt@kms_atomic_transition@plane-all-modeset-transition:
- shard-iclb: NOTRUN -> [SKIP][39] ([i915#1769])
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb8/igt@kms_atomic_transition@plane-all-modeset-transition.html
- shard-tglb: NOTRUN -> [SKIP][40] ([i915#1769])
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb8/igt@kms_atomic_transition@plane-all-modeset-transition.html
* igt@kms_big_fb@4-tiled-max-hw-stride-64bpp-rotate-0:
- shard-tglb: NOTRUN -> [SKIP][41] ([i915#5286]) +3 similar issues
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb1/igt@kms_big_fb@4-tiled-max-hw-stride-64bpp-rotate-0.html
* igt@kms_big_fb@4-tiled-max-hw-stride-64bpp-rotate-0-async-flip:
- shard-iclb: NOTRUN -> [SKIP][42] ([i915#5286]) +3 similar issues
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb6/igt@kms_big_fb@4-tiled-max-hw-stride-64bpp-rotate-0-async-flip.html
* igt@kms_big_fb@linear-8bpp-rotate-270:
- shard-tglb: NOTRUN -> [SKIP][43] ([fdo#111614])
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb7/igt@kms_big_fb@linear-8bpp-rotate-270.html
- shard-iclb: NOTRUN -> [SKIP][44] ([fdo#110725] / [fdo#111614])
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb8/igt@kms_big_fb@linear-8bpp-rotate-270.html
* igt@kms_big_fb@yf-tiled-8bpp-rotate-180:
- shard-iclb: NOTRUN -> [SKIP][45] ([fdo#110723])
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb1/igt@kms_big_fb@yf-tiled-8bpp-rotate-180.html
* igt@kms_big_fb@yf-tiled-max-hw-stride-32bpp-rotate-180-hflip-async-flip:
- shard-tglb: NOTRUN -> [SKIP][46] ([fdo#111615]) +1 similar issue
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb3/igt@kms_big_fb@yf-tiled-max-hw-stride-32bpp-rotate-180-hflip-async-flip.html
* igt@kms_big_joiner@2x-modeset:
- shard-tglb: NOTRUN -> [SKIP][47] ([i915#2705])
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb5/igt@kms_big_joiner@2x-modeset.html
- shard-iclb: NOTRUN -> [SKIP][48] ([i915#2705])
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb7/igt@kms_big_joiner@2x-modeset.html
* igt@kms_ccs@pipe-a-crc-primary-basic-yf_tiled_ccs:
- shard-tglb: NOTRUN -> [SKIP][49] ([fdo#111615] / [i915#3689]) +2 similar issues
[49]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb1/igt@kms_ccs@pipe-a-crc-primary-basic-yf_tiled_ccs.html
* igt@kms_ccs@pipe-a-crc-sprite-planes-basic-y_tiled_gen12_rc_ccs:
- shard-iclb: NOTRUN -> [SKIP][50] ([fdo#109278]) +12 similar issues
[50]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb8/igt@kms_ccs@pipe-a-crc-sprite-planes-basic-y_tiled_gen12_rc_ccs.html
* igt@kms_ccs@pipe-b-bad-pixel-format-y_tiled_gen12_mc_ccs:
- shard-tglb: NOTRUN -> [SKIP][51] ([i915#3689] / [i915#3886]) +1 similar issue
[51]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb1/igt@kms_ccs@pipe-b-bad-pixel-format-y_tiled_gen12_mc_ccs.html
- shard-glk: NOTRUN -> [SKIP][52] ([fdo#109271] / [i915#3886]) +10 similar issues
[52]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-glk2/igt@kms_ccs@pipe-b-bad-pixel-format-y_tiled_gen12_mc_ccs.html
* igt@kms_ccs@pipe-b-ccs-on-another-bo-y_tiled_gen12_rc_ccs_cc:
- shard-apl: NOTRUN -> [SKIP][53] ([fdo#109271] / [i915#3886]) +6 similar issues
[53]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-apl6/igt@kms_ccs@pipe-b-ccs-on-another-bo-y_tiled_gen12_rc_ccs_cc.html
* igt@kms_ccs@pipe-c-crc-primary-basic-4_tiled_dg2_rc_ccs_cc:
- shard-tglb: NOTRUN -> [SKIP][54] ([i915#6095]) +1 similar issue
[54]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb5/igt@kms_ccs@pipe-c-crc-primary-basic-4_tiled_dg2_rc_ccs_cc.html
* igt@kms_ccs@pipe-c-random-ccs-data-y_tiled_gen12_rc_ccs_cc:
- shard-iclb: NOTRUN -> [SKIP][55] ([fdo#109278] / [i915#3886]) +2 similar issues
[55]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb8/igt@kms_ccs@pipe-c-random-ccs-data-y_tiled_gen12_rc_ccs_cc.html
* igt@kms_ccs@pipe-d-crc-primary-basic-4_tiled_dg2_rc_ccs_cc:
- shard-tglb: NOTRUN -> [SKIP][56] ([i915#3689]) +1 similar issue
[56]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb7/igt@kms_ccs@pipe-d-crc-primary-basic-4_tiled_dg2_rc_ccs_cc.html
* igt@kms_cdclk@plane-scaling:
- shard-iclb: NOTRUN -> [SKIP][57] ([i915#3742])
[57]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb4/igt@kms_cdclk@plane-scaling.html
- shard-tglb: NOTRUN -> [SKIP][58] ([i915#3742])
[58]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb8/igt@kms_cdclk@plane-scaling.html
* igt@kms_chamelium@hdmi-audio-edid:
- shard-glk: NOTRUN -> [SKIP][59] ([fdo#109271] / [fdo#111827]) +6 similar issues
[59]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-glk6/igt@kms_chamelium@hdmi-audio-edid.html
* igt@kms_chamelium@hdmi-hpd-storm:
- shard-apl: NOTRUN -> [SKIP][60] ([fdo#109271] / [fdo#111827]) +4 similar issues
[60]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-apl1/igt@kms_chamelium@hdmi-hpd-storm.html
- shard-tglb: NOTRUN -> [SKIP][61] ([fdo#109284] / [fdo#111827]) +2 similar issues
[61]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb3/igt@kms_chamelium@hdmi-hpd-storm.html
- shard-iclb: NOTRUN -> [SKIP][62] ([fdo#109284] / [fdo#111827]) +2 similar issues
[62]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb5/igt@kms_chamelium@hdmi-hpd-storm.html
* igt@kms_chamelium@vga-hpd-without-ddc:
- shard-snb: NOTRUN -> [SKIP][63] ([fdo#109271] / [fdo#111827]) +2 similar issues
[63]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-snb7/igt@kms_chamelium@vga-hpd-without-ddc.html
* igt@kms_cursor_crc@cursor-offscreen-32x32:
- shard-tglb: NOTRUN -> [SKIP][64] ([i915#3555]) +1 similar issue
[64]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb8/igt@kms_cursor_crc@cursor-offscreen-32x32.html
* igt@kms_cursor_crc@cursor-suspend@pipe-c-dp-1:
- shard-apl: [PASS][65] -> [DMESG-WARN][66] ([i915#180]) +2 similar issues
[65]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-apl3/igt@kms_cursor_crc@cursor-suspend@pipe-c-dp-1.html
[66]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-apl8/igt@kms_cursor_crc@cursor-suspend@pipe-c-dp-1.html
* igt@kms_cursor_legacy@cursorb-vs-flipa@atomic-transitions-varying-size:
- shard-tglb: NOTRUN -> [SKIP][67] ([fdo#109274] / [fdo#111825]) +6 similar issues
[67]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb8/igt@kms_cursor_legacy@cursorb-vs-flipa@atomic-transitions-varying-size.html
* igt@kms_cursor_legacy@cursorb-vs-flipa@legacy:
- shard-iclb: NOTRUN -> [SKIP][68] ([fdo#109274]) +11 similar issues
[68]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb6/igt@kms_cursor_legacy@cursorb-vs-flipa@legacy.html
* igt@kms_cursor_legacy@flip-vs-cursor@atomic-transitions-varying-size:
- shard-glk: [PASS][69] -> [FAIL][70] ([i915#2346]) +1 similar issue
[69]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-glk9/igt@kms_cursor_legacy@flip-vs-cursor@atomic-transitions-varying-size.html
[70]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-glk5/igt@kms_cursor_legacy@flip-vs-cursor@atomic-transitions-varying-size.html
* igt@kms_flip@2x-flip-vs-modeset:
- shard-tglb: NOTRUN -> [SKIP][71] ([fdo#109274] / [fdo#111825] / [i915#3637]) +4 similar issues
[71]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb7/igt@kms_flip@2x-flip-vs-modeset.html
* igt@kms_flip_scaled_crc@flip-32bpp-yftile-to-64bpp-yftile-downscaling@pipe-a-default-mode:
- shard-iclb: NOTRUN -> [SKIP][72] ([i915#2672]) +6 similar issues
[72]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb2/igt@kms_flip_scaled_crc@flip-32bpp-yftile-to-64bpp-yftile-downscaling@pipe-a-default-mode.html
* igt@kms_flip_scaled_crc@flip-32bpp-yftileccs-to-64bpp-yftile-downscaling@pipe-a-valid-mode:
- shard-tglb: NOTRUN -> [SKIP][73] ([i915#2587] / [i915#2672]) +2 similar issues
[73]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb2/igt@kms_flip_scaled_crc@flip-32bpp-yftileccs-to-64bpp-yftile-downscaling@pipe-a-valid-mode.html
* igt@kms_flip_scaled_crc@flip-32bpp-yftileccs-to-64bpp-yftile-upscaling@pipe-a-valid-mode:
- shard-iclb: NOTRUN -> [SKIP][74] ([i915#2587] / [i915#2672]) +2 similar issues
[74]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb7/igt@kms_flip_scaled_crc@flip-32bpp-yftileccs-to-64bpp-yftile-upscaling@pipe-a-valid-mode.html
* igt@kms_flip_scaled_crc@flip-32bpp-ytile-to-32bpp-ytilegen12rcccs-downscaling@pipe-a-default-mode:
- shard-iclb: NOTRUN -> [SKIP][75] ([i915#2672] / [i915#3555])
[75]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb2/igt@kms_flip_scaled_crc@flip-32bpp-ytile-to-32bpp-ytilegen12rcccs-downscaling@pipe-a-default-mode.html
* igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-cur-indfb-draw-pwrite:
- shard-tglb: NOTRUN -> [SKIP][76] ([fdo#109280] / [fdo#111825]) +12 similar issues
[76]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb5/igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-cur-indfb-draw-pwrite.html
* igt@kms_frontbuffer_tracking@fbc-rgb101010-draw-render:
- shard-snb: [PASS][77] -> [SKIP][78] ([fdo#109271])
[77]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-snb7/igt@kms_frontbuffer_tracking@fbc-rgb101010-draw-render.html
[78]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-snb2/igt@kms_frontbuffer_tracking@fbc-rgb101010-draw-render.html
* igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-indfb-plflip-blt:
- shard-tglb: NOTRUN -> [SKIP][79] ([i915#6497]) +5 similar issues
[79]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb1/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-indfb-plflip-blt.html
* igt@kms_frontbuffer_tracking@fbcpsr-2p-primscrn-pri-shrfb-draw-mmap-gtt:
- shard-iclb: NOTRUN -> [SKIP][80] ([fdo#109280]) +12 similar issues
[80]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb2/igt@kms_frontbuffer_tracking@fbcpsr-2p-primscrn-pri-shrfb-draw-mmap-gtt.html
* igt@kms_frontbuffer_tracking@psr-2p-scndscrn-pri-indfb-draw-mmap-cpu:
- shard-snb: NOTRUN -> [SKIP][81] ([fdo#109271]) +120 similar issues
[81]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-snb7/igt@kms_frontbuffer_tracking@psr-2p-scndscrn-pri-indfb-draw-mmap-cpu.html
* igt@kms_invalid_mode@clock-too-high@edp-1-pipe-c:
- shard-iclb: NOTRUN -> [SKIP][82] ([i915#6403]) +2 similar issues
[82]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb2/igt@kms_invalid_mode@clock-too-high@edp-1-pipe-c.html
* igt@kms_invalid_mode@clock-too-high@edp-1-pipe-d:
- shard-tglb: NOTRUN -> [SKIP][83] ([i915#6403]) +3 similar issues
[83]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb7/igt@kms_invalid_mode@clock-too-high@edp-1-pipe-d.html
* igt@kms_plane_alpha_blend@alpha-opaque-fb@pipe-a-dp-1:
- shard-apl: NOTRUN -> [FAIL][84] ([i915#4573]) +2 similar issues
[84]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-apl3/igt@kms_plane_alpha_blend@alpha-opaque-fb@pipe-a-dp-1.html
* igt@kms_plane_alpha_blend@alpha-transparent-fb@pipe-b-hdmi-a-2:
- shard-glk: NOTRUN -> [FAIL][85] ([i915#4573]) +5 similar issues
[85]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-glk8/igt@kms_plane_alpha_blend@alpha-transparent-fb@pipe-b-hdmi-a-2.html
* igt@kms_plane_multiple@tiling-4:
- shard-iclb: NOTRUN -> [SKIP][86] ([i915#3555]) +1 similar issue
[86]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb1/igt@kms_plane_multiple@tiling-4.html
* igt@kms_plane_scaling@planes-upscale-factor-0-25-downscale-factor-0-25@pipe-a-hdmi-a-1:
- shard-glk: NOTRUN -> [SKIP][87] ([fdo#109271]) +130 similar issues
[87]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-glk8/igt@kms_plane_scaling@planes-upscale-factor-0-25-downscale-factor-0-25@pipe-a-hdmi-a-1.html
* igt@kms_plane_scaling@planes-upscale-factor-0-25-downscale-factor-0-25@pipe-b-edp-1:
- shard-iclb: NOTRUN -> [SKIP][88] ([i915#5235]) +2 similar issues
[88]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb5/igt@kms_plane_scaling@planes-upscale-factor-0-25-downscale-factor-0-25@pipe-b-edp-1.html
* igt@kms_plane_scaling@planes-upscale-factor-0-25-downscale-factor-0-25@pipe-c-edp-1:
- shard-tglb: NOTRUN -> [SKIP][89] ([i915#5235]) +3 similar issues
[89]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb7/igt@kms_plane_scaling@planes-upscale-factor-0-25-downscale-factor-0-25@pipe-c-edp-1.html
* igt@kms_psr2_sf@overlay-plane-move-continuous-exceed-fully-sf:
- shard-iclb: NOTRUN -> [SKIP][90] ([i915#658])
[90]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb6/igt@kms_psr2_sf@overlay-plane-move-continuous-exceed-fully-sf.html
- shard-apl: NOTRUN -> [SKIP][91] ([fdo#109271] / [i915#658])
[91]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-apl2/igt@kms_psr2_sf@overlay-plane-move-continuous-exceed-fully-sf.html
- shard-tglb: NOTRUN -> [SKIP][92] ([i915#2920])
[92]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb1/igt@kms_psr2_sf@overlay-plane-move-continuous-exceed-fully-sf.html
* igt@kms_psr2_sf@overlay-primary-update-sf-dmg-area:
- shard-glk: NOTRUN -> [SKIP][93] ([fdo#109271] / [i915#658]) +3 similar issues
[93]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-glk8/igt@kms_psr2_sf@overlay-primary-update-sf-dmg-area.html
* igt@kms_psr2_su@page_flip-xrgb8888:
- shard-iclb: [PASS][94] -> [SKIP][95] ([fdo#109642] / [fdo#111068] / [i915#658])
[94]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-iclb2/igt@kms_psr2_su@page_flip-xrgb8888.html
[95]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb3/igt@kms_psr2_su@page_flip-xrgb8888.html
* igt@kms_psr@psr2_primary_blt:
- shard-iclb: [PASS][96] -> [SKIP][97] ([fdo#109441])
[96]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-iclb2/igt@kms_psr@psr2_primary_blt.html
[97]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb5/igt@kms_psr@psr2_primary_blt.html
* igt@kms_psr@psr2_sprite_plane_onoff:
- shard-apl: NOTRUN -> [SKIP][98] ([fdo#109271]) +119 similar issues
[98]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-apl6/igt@kms_psr@psr2_sprite_plane_onoff.html
- shard-tglb: NOTRUN -> [FAIL][99] ([i915#132] / [i915#3467]) +1 similar issue
[99]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb7/igt@kms_psr@psr2_sprite_plane_onoff.html
- shard-iclb: NOTRUN -> [SKIP][100] ([fdo#109441]) +1 similar issue
[100]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb5/igt@kms_psr@psr2_sprite_plane_onoff.html
* igt@kms_psr_stress_test@invalidate-primary-flip-overlay:
- shard-tglb: [PASS][101] -> [SKIP][102] ([i915#5519])
[101]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-tglb2/igt@kms_psr_stress_test@invalidate-primary-flip-overlay.html
[102]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb1/igt@kms_psr_stress_test@invalidate-primary-flip-overlay.html
* igt@perf@polling-parameterized:
- shard-glk: [PASS][103] -> [FAIL][104] ([i915#5639])
[103]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-glk8/igt@perf@polling-parameterized.html
[104]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-glk1/igt@perf@polling-parameterized.html
* igt@prime_vgem@basic-userptr:
- shard-tglb: NOTRUN -> [SKIP][105] ([fdo#109295] / [i915#3301])
[105]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb3/igt@prime_vgem@basic-userptr.html
- shard-iclb: NOTRUN -> [SKIP][106] ([fdo#109295] / [i915#3301])
[106]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb1/igt@prime_vgem@basic-userptr.html
* igt@prime_vgem@coherency-gtt:
- shard-iclb: NOTRUN -> [SKIP][107] ([fdo#109292] / [fdo#109295])
[107]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb8/igt@prime_vgem@coherency-gtt.html
- shard-tglb: NOTRUN -> [SKIP][108] ([fdo#109295] / [fdo#111656])
[108]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb8/igt@prime_vgem@coherency-gtt.html
* igt@prime_vgem@fence-read-hang:
- shard-iclb: NOTRUN -> [SKIP][109] ([fdo#109295])
[109]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb7/igt@prime_vgem@fence-read-hang.html
- shard-tglb: NOTRUN -> [SKIP][110] ([fdo#109295])
[110]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb5/igt@prime_vgem@fence-read-hang.html
* igt@sysfs_clients@fair-3:
- shard-apl: NOTRUN -> [SKIP][111] ([fdo#109271] / [i915#2994]) +2 similar issues
[111]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-apl3/igt@sysfs_clients@fair-3.html
- shard-glk: NOTRUN -> [SKIP][112] ([fdo#109271] / [i915#2994]) +1 similar issue
[112]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-glk2/igt@sysfs_clients@fair-3.html
* igt@sysfs_clients@sema-50:
- shard-tglb: NOTRUN -> [SKIP][113] ([i915#2994])
[113]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb2/igt@sysfs_clients@sema-50.html
- shard-iclb: NOTRUN -> [SKIP][114] ([i915#2994])
[114]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb3/igt@sysfs_clients@sema-50.html
#### Possible fixes ####
* igt@gem_ctx_exec@basic-nohangcheck:
- shard-tglb: [FAIL][115] ([i915#6268]) -> [PASS][116]
[115]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-tglb1/igt@gem_ctx_exec@basic-nohangcheck.html
[116]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb7/igt@gem_ctx_exec@basic-nohangcheck.html
* igt@gem_exec_balancer@parallel:
- shard-iclb: [SKIP][117] ([i915#4525]) -> [PASS][118]
[117]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-iclb7/igt@gem_exec_balancer@parallel.html
[118]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb4/igt@gem_exec_balancer@parallel.html
* igt@gem_exec_fair@basic-none-share@rcs0:
- shard-tglb: [FAIL][119] ([i915#2842]) -> [PASS][120]
[119]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-tglb5/igt@gem_exec_fair@basic-none-share@rcs0.html
[120]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb1/igt@gem_exec_fair@basic-none-share@rcs0.html
* igt@gem_exec_fair@basic-none-solo@rcs0:
- shard-apl: [FAIL][121] ([i915#2842]) -> [PASS][122]
[121]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-apl2/igt@gem_exec_fair@basic-none-solo@rcs0.html
[122]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-apl8/igt@gem_exec_fair@basic-none-solo@rcs0.html
* igt@gem_exec_fair@basic-pace-share@rcs0:
- shard-glk: [FAIL][123] ([i915#2842]) -> [PASS][124]
[123]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-glk1/igt@gem_exec_fair@basic-pace-share@rcs0.html
[124]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-glk2/igt@gem_exec_fair@basic-pace-share@rcs0.html
* igt@gem_workarounds@suspend-resume:
- shard-apl: [DMESG-WARN][125] ([i915#180]) -> [PASS][126] +3 similar issues
[125]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-apl1/igt@gem_workarounds@suspend-resume.html
[126]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-apl1/igt@gem_workarounds@suspend-resume.html
* igt@gen9_exec_parse@allowed-single:
- shard-glk: [DMESG-WARN][127] ([i915#5566] / [i915#716]) -> [PASS][128]
[127]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-glk2/igt@gen9_exec_parse@allowed-single.html
[128]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-glk1/igt@gen9_exec_parse@allowed-single.html
* igt@i915_pm_dc@dc6-dpms:
- shard-iclb: [FAIL][129] ([i915#3989] / [i915#454]) -> [PASS][130]
[129]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-iclb3/igt@i915_pm_dc@dc6-dpms.html
[130]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb4/igt@i915_pm_dc@dc6-dpms.html
* igt@i915_suspend@sysfs-reader:
- shard-snb: [SKIP][131] ([fdo#109271]) -> [PASS][132]
[131]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-snb6/igt@i915_suspend@sysfs-reader.html
[132]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-snb5/igt@i915_suspend@sysfs-reader.html
* igt@kms_addfb_basic@legacy-format:
- shard-iclb: [INCOMPLETE][133] -> [PASS][134]
[133]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-iclb3/igt@kms_addfb_basic@legacy-format.html
[134]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb4/igt@kms_addfb_basic@legacy-format.html
* igt@kms_flip@2x-flip-vs-expired-vblank@ac-hdmi-a1-hdmi-a2:
- shard-glk: [FAIL][135] ([i915#79]) -> [PASS][136]
[135]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-glk7/igt@kms_flip@2x-flip-vs-expired-vblank@ac-hdmi-a1-hdmi-a2.html
[136]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-glk5/igt@kms_flip@2x-flip-vs-expired-vblank@ac-hdmi-a1-hdmi-a2.html
* igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-indfb-msflip-blt:
- shard-glk: [FAIL][137] ([i915#1888] / [i915#2546]) -> [PASS][138]
[137]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-glk3/igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-indfb-msflip-blt.html
[138]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-glk5/igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-indfb-msflip-blt.html
* igt@kms_hdmi_inject@inject-audio:
- shard-tglb: [SKIP][139] ([i915#433]) -> [PASS][140]
[139]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-tglb2/igt@kms_hdmi_inject@inject-audio.html
[140]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-tglb1/igt@kms_hdmi_inject@inject-audio.html
* igt@kms_plane_scaling@plane-scaler-with-clipping-clamping-pixel-formats@pipe-b-edp-1:
- shard-iclb: [SKIP][141] ([i915#5176]) -> [PASS][142] +1 similar issue
[141]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-iclb3/igt@kms_plane_scaling@plane-scaler-with-clipping-clamping-pixel-formats@pipe-b-edp-1.html
[142]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb7/igt@kms_plane_scaling@plane-scaler-with-clipping-clamping-pixel-formats@pipe-b-edp-1.html
* igt@kms_psr@psr2_cursor_mmap_gtt:
- shard-iclb: [SKIP][143] ([fdo#109441]) -> [PASS][144]
[143]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-iclb5/igt@kms_psr@psr2_cursor_mmap_gtt.html
[144]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb2/igt@kms_psr@psr2_cursor_mmap_gtt.html
* igt@kms_vblank@pipe-a-ts-continuation-idle-hang:
- shard-glk: [SKIP][145] ([fdo#109271]) -> [PASS][146]
[145]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-glk7/igt@kms_vblank@pipe-a-ts-continuation-idle-hang.html
[146]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-glk7/igt@kms_vblank@pipe-a-ts-continuation-idle-hang.html
#### Warnings ####
* igt@kms_psr2_sf@cursor-plane-move-continuous-exceed-sf:
- shard-iclb: [SKIP][147] ([i915#2920]) -> [SKIP][148] ([i915#658])
[147]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-iclb2/igt@kms_psr2_sf@cursor-plane-move-continuous-exceed-sf.html
[148]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb3/igt@kms_psr2_sf@cursor-plane-move-continuous-exceed-sf.html
* igt@kms_psr2_sf@overlay-plane-update-continuous-sf:
- shard-iclb: [SKIP][149] ([fdo#111068] / [i915#658]) -> [SKIP][150] ([i915#2920])
[149]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-iclb8/igt@kms_psr2_sf@overlay-plane-update-continuous-sf.html
[150]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-iclb2/igt@kms_psr2_sf@overlay-plane-update-continuous-sf.html
* igt@runner@aborted:
- shard-apl: ([FAIL][151], [FAIL][152], [FAIL][153], [FAIL][154], [FAIL][155]) ([fdo#109271] / [i915#180] / [i915#3002] / [i915#4312]) -> ([FAIL][156], [FAIL][157], [FAIL][158], [FAIL][159], [FAIL][160]) ([fdo#109271] / [i915#3002] / [i915#4312])
[151]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-apl8/igt@runner@aborted.html
[152]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-apl2/igt@runner@aborted.html
[153]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-apl1/igt@runner@aborted.html
[154]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-apl3/igt@runner@aborted.html
[155]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12221/shard-apl1/igt@runner@aborted.html
[156]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-apl1/igt@runner@aborted.html
[157]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-apl8/igt@runner@aborted.html
[158]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-apl8/igt@runner@aborted.html
[159]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-apl6/igt@runner@aborted.html
[160]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/shard-apl7/igt@runner@aborted.html
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109274]: https://bugs.freedesktop.org/show_bug.cgi?id=109274
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109279]: https://bugs.freedesktop.org/show_bug.cgi?id=109279
[fdo#109280]: https://bugs.freedesktop.org/show_bug.cgi?id=109280
[fdo#109283]: https://bugs.freedesktop.org/show_bug.cgi?id=109283
[fdo#109284]: https://bugs.freedesktop.org/show_bug.cgi?id=109284
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109289]: https://bugs.freedesktop.org/show_bug.cgi?id=109289
[fdo#109291]: https://bugs.freedesktop.org/show_bug.cgi?id=109291
[fdo#109292]: https://bugs.freedesktop.org/show_bug.cgi?id=109292
[fdo#109295]: https://bugs.freedesktop.org/show_bug.cgi?id=109295
[fdo#109300]: https://bugs.freedesktop.org/show_bug.cgi?id=109300
[fdo#109302]: https://bugs.freedesktop.org/show_bug.cgi?id=109302
[fdo#109303]: https://bugs.freedesktop.org/show_bug.cgi?id=109303
[fdo#109307]: https://bugs.freedesktop.org/show_bug.cgi?id=109307
[fdo#109308]: https://bugs.freedesktop.org/show_bug.cgi?id=109308
[fdo#109312]: https://bugs.freedesktop.org/show_bug.cgi?id=109312
[fdo#109313]: https://bugs.freedesktop.org/show_bug.cgi?id=109313
[fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
[fdo#109506]: https://bugs.freedesktop.org/show_bug.cgi?id=109506
[fdo#109642]: https://bugs.freedesktop.org/show_bug.cgi?id=109642
[fdo#110189]: https://bugs.freedesktop.org/show_bug.cgi?id=110189
[fdo#110542]: https://bugs.freedesktop.org/show_bug.cgi?id=110542
[fdo#110723]: https://bugs.freedesktop.org/show_bug.cgi?id=110723
[fdo#110725]: https://bugs.freedesktop.org/show_bug.cgi?id=110725
[fdo#111068]: https://bugs.freedesktop.org/show_bug.cgi?id=111068
[fdo#111614]: https://bugs.freedesktop.org/show_bug.cgi?id=111614
[fdo#111615]: https://bugs.freedesktop.org/show_bug.cgi?id=111615
[fdo#111644]: https://bugs.freedesktop.org/show_bug.cgi?id=111644
[fdo#111656]: https://bugs.freedesktop.org/show_bug.cgi?id=111656
[fdo#111825]: https://bugs.freedesktop.org/show_bug.cgi?id=111825
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[fdo#112054]: https://bugs.freedesktop.org/show_bug.cgi?id=112054
[fdo#112283]: https://bugs.freedesktop.org/show_bug.cgi?id=112283
[i915#1063]: https://gitlab.freedesktop.org/drm/intel/issues/1063
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1099]: https://gitlab.freedesktop.org/drm/intel/issues/1099
[i915#1155]: https://gitlab.freedesktop.org/drm/intel/issues/1155
[i915#132]: https://gitlab.freedesktop.org/drm/intel/issues/132
[i915#1397]: https://gitlab.freedesktop.org/drm/intel/issues/1397
[i915#1755]: https://gitlab.freedesktop.org/drm/intel/issues/1755
[i915#1759]: https://gitlab.freedesktop.org/drm/intel/issues/1759
[i915#1769]: https://gitlab.freedesktop.org/drm/intel/issues/1769
[i915#180]: https://gitlab.freedesktop.org/drm/intel/issues/180
[i915#1825]: https://gitlab.freedesktop.org/drm/intel/issues/1825
[i915#1839]: https://gitlab.freedesktop.org/drm/intel/issues/1839
[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#1849]: https://gitlab.freedesktop.org/drm/intel/issues/1849
[i915#1888]: https://gitlab.freedesktop.org/drm/intel/issues/1888
[i915#1902]: https://gitlab.freedesktop.org/drm/intel/issues/1902
[i915#1937]: https://gitlab.freedesktop.org/drm/intel/issues/1937
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#2346]: https://gitlab.freedesktop.org/drm/intel/issues/2346
[i915#2410]: https://gitlab.freedesktop.org/drm/intel/issues/2410
[i915#2433]: https://gitlab.freedesktop.org/drm/intel/issues/2433
[i915#2434]: https://gitlab.freedesktop.org/drm/intel/issues/2434
[i915#2436]: https://gitlab.freedesktop.org/drm/intel/issues/2436
[i915#2437]: https://gitlab.freedesktop.org/drm/intel/issues/2437
[i915#2521]: https://gitlab.freedesktop.org/drm/intel/issues/2521
[i915#2527]: https://gitlab.freedesktop.org/drm/intel/issues/2527
[i915#2546]: https://gitlab.freedesktop.org/drm/intel/issues/2546
[i915#2582]: https://gitlab.freedesktop.org/drm/intel/issues/2582
[i915#2587]: https://gitlab.freedesktop.org/drm/intel/issues/2587
[i915#2658]: https://gitlab.freedesktop.org/drm/intel/issues/2658
[i915#2672]: https://gitlab.freedesktop.org/drm/intel/issues/2672
[i915#2681]: https://gitlab.freedesktop.org/drm/intel/issues/2681
[i915#2705]: https://gitlab.freedesktop.org/drm/intel/issues/2705
[i915#280]: https://gitlab.freedesktop.org/drm/intel/issues/280
[i915#2842]: https://gitlab.freedesktop.org/drm/intel/issues/2842
[i915#2846]: https://gitlab.freedesktop.org/drm/intel/issues/2846
[i915#2856]: https://gitlab.freedesktop.org/drm/intel/issues/2856
[i915#2920]: https://gitlab.freedesktop.org/drm/intel/issues/2920
[i915#2994]: https://gitlab.freedesktop.org/drm/intel/issues/2994
[i915#3002]: https://gitlab.freedesktop.org/drm/intel/issues/3002
[i915#3012]: https://gitlab.freedesktop.org/drm/intel/issues/3012
[i915#3116]: https://gitlab.freedesktop.org/drm/intel/issues/3116
[i915#315]: https://gitlab.freedesktop.org/drm/intel/issues/315
[i915#3281]: https://gitlab.freedesktop.org/drm/intel/issues/3281
[i915#3282]: https://gitlab.freedesktop.org/drm/intel/issues/3282
[i915#3291]: https://gitlab.freedesktop.org/drm/intel/issues/3291
[i915#3297]: https://gitlab.freedesktop.org/drm/intel/issues/3297
[i915#3299]: https://gitlab.freedesktop.org/drm/intel/issues/3299
[i915#3301]: https://gitlab.freedesktop.org/drm/intel/issues/3301
[i915#3318]: https://gitlab.freedesktop.org/drm/intel/issues/3318
[i915#3323]: https://gitlab.freedesktop.org/drm/intel/issues/3323
[i915#3359]: https://gitlab.freedesktop.org/drm/intel/issues/3359
[i915#3361]: https://gitlab.freedesktop.org/drm/intel/issues/3361
[i915#3458]: https://gitlab.freedesktop.org/drm/intel/issues/3458
[i915#3467]: https://gitlab.freedesktop.org/drm/intel/issues/3467
[i915#3469]: https://gitlab.freedesktop.org/drm/intel/issues/3469
[i915#3528]: https://gitlab.freedesktop.org/drm/intel/issues/3528
[i915#3539]: https://gitlab.freedesktop.org/drm/intel/issues/3539
[i915#3546]: https://gitlab.freedesktop.org/drm/intel/issues/3546
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#3558]: https://gitlab.freedesktop.org/drm/intel/issues/3558
[i915#3591]: https://gitlab.freedesktop.org/drm/intel/issues/3591
[i915#3637]: https://gitlab.freedesktop.org/drm/intel/issues/3637
[i915#3638]: https://gitlab.freedesktop.org/drm/intel/issues/3638
[i915#3689]: https://gitlab.freedesktop.org/drm/intel/issues/3689
[i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
[i915#3734]: https://gitlab.freedesktop.org/drm/intel/issues/3734
[i915#3742]: https://gitlab.freedesktop.org/drm/intel/issues/3742
[i915#3743]: https://gitlab.freedesktop.org/drm/intel/issues/3743
[i915#3804]: https://gitlab.freedesktop.org/drm/intel/issues/3804
[i915#3825]: https://gitlab.freedesktop.org/drm/intel/issues/3825
[i915#3826]: https://gitlab.freedesktop.org/drm/intel/issues/3826
[i915#3840]: https://gitlab.freedesktop.org/drm/intel/issues/3840
[i915#3886]: https://gitlab.freedesktop.org/drm/intel/issues/3886
[i915#3936]: https://gitlab.freedesktop.org/drm/intel/issues/3936
[i915#3938]: https://gitlab.freedesktop.org/drm/intel/issues/3938
[i915#3952]: https://gitlab.freedesktop.org/drm/intel/issues/3952
[i915#3955]: https://gitlab.freedesktop.org/drm/intel/issues/3955
[i915#3966]: https://gitlab.freedesktop.org/drm/intel/issues/3966
[i915#3989]: https://gitlab.freedesktop.org/drm/intel/issues/3989
[i915#4036]: https://gitlab.freedesktop.org/drm/intel/issues/4036
[i915#404]: https://gitlab.freedesktop.org/drm/intel/issues/404
[i915#4070]: https://gitlab.freedesktop.org/drm/intel/issues/4070
[i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
[i915#4078]: https://gitlab.freedesktop.org/drm/intel/issues/4078
[i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
[i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
[i915#4098]: https://gitlab.freedesktop.org/drm/intel/issues/4098
[i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
[i915#4212]: https://gitlab.freedesktop.org/drm/intel/issues/4212
[i915#4213]: https://gitlab.freedesktop.org/drm/intel/issues/4213
[i915#4215]: https://gitlab.freedesktop.org/drm/intel/issues/4215
[i915#426]: https://gitlab.freedesktop.org/drm/intel/issues/426
[i915#4270]: https://gitlab.freedesktop.org/drm/intel/issues/4270
[i915#4281]: https://gitlab.freedesktop.org/drm/intel/issues/4281
[i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
[i915#433]: https://gitlab.freedesktop.org/drm/intel/issues/433
[i915#4387]: https://gitlab.freedesktop.org/drm/intel/issues/4387
[i915#4391]: https://gitlab.freedesktop.org/drm/intel/issues/4391
[i915#4525]: https://gitlab.freedesktop.org/drm/intel/issues/4525
[i915#4528]: https://gitlab.freedesktop.org/drm/intel/issues/4528
[i915#4538]: https://gitlab.freedesktop.org/drm/intel/issues/4538
[i915#454]: https://gitlab.freedesktop.org/drm/intel/issues/454
[i915#4565]: https://gitlab.freedesktop.org/drm/intel/issues/4565
[i915#4573]: https://gitlab.freedesktop.org/drm/intel/issues/4573
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#4771]: https://gitlab.freedesktop.org/drm/intel/issues/4771
[i915#4812]: https://gitlab.freedesktop.org/drm/intel/issues/4812
[i915#4818]: https://gitlab.freedesktop.org/drm/intel/issues/4818
[i915#4833]: https://gitlab.freedesktop.org/drm/intel/issues/4833
[i915#4852]: https://gitlab.freedesktop.org/drm/intel/issues/4852
[i915#4855]: https://gitlab.freedesktop.org/drm/intel/issues/4855
[i915#4859]: https://gitlab.freedesktop.org/drm/intel/issues/4859
[i915#4860]: https://gitlab.freedesktop.org/drm/intel/issues/4860
[i915#4877]: https://gitlab.freedesktop.org/drm/intel/issues/4877
[i915#4879]: https://gitlab.freedesktop.org/drm/intel/issues/4879
[i915#4881]: https://gitlab.freedesktop.org/drm/intel/issues/4881
[i915#4883]: https://gitlab.freedesktop.org/drm/intel/issues/4883
[i915#4884]: https://gitlab.freedesktop.org/drm/intel/issues/4884
[i915#4958]: https://gitlab.freedesktop.org/drm/intel/issues/4958
[i915#4991]: https://gitlab.freedesktop.org/drm/intel/issues/4991
[i915#5176]: https://gitlab.freedesktop.org/drm/intel/issues/5176
[i915#5182]: https://gitlab.freedesktop.org/drm/intel/issues/5182
[i915#5235]: https://gitlab.freedesktop.org/drm/intel/issues/5235
[i915#5286]: https://gitlab.freedesktop.org/drm/intel/issues/5286
[i915#5288]: https://gitlab.freedesktop.org/drm/intel/issues/5288
[i915#5289]: https://gitlab.freedesktop.org/drm/intel/issues/5289
[i915#5325]: https://gitlab.freedesktop.org/drm/intel/issues/5325
[i915#5327]: https://gitlab.freedesktop.org/drm/intel/issues/5327
[i915#533]: https://gitlab.freedesktop.org/drm/intel/issues/533
[i915#5461]: https://gitlab.freedesktop.org/drm/intel/issues/5461
[i915#5519]: https://gitlab.freedesktop.org/drm/intel/issues/5519
[i915#5563]: https://gitlab.freedesktop.org/drm/intel/issues/5563
[i915#5566]: https://gitlab.freedesktop.org/drm/intel/issues/5566
[i915#5639]: https://gitlab.freedesktop.org/drm/intel/issues/5639
[i915#5723]: https://gitlab.freedesktop.org/drm/intel/issues/5723
[i915#5784]: https://gitlab.freedesktop.org/drm/intel/issues/5784
[i915#6095]: https://gitlab.freedesktop.org/drm/intel/issues/6095
[i915#6117]: https://gitlab.freedesktop.org/drm/intel/issues/6117
[i915#6227]: https://gitlab.freedesktop.org/drm/intel/issues/6227
[i915#6230]: https://gitlab.freedesktop.org/drm/intel/issues/6230
[i915#6245]: https://gitlab.freedesktop.org/drm/intel/issues/6245
[i915#6247]: https://gitlab.freedesktop.org/drm/intel/issues/6247
[i915#6248]: https://gitlab.freedesktop.org/drm/intel/issues/6248
[i915#6251]: https://gitlab.freedesktop.org/drm/intel/issues/6251
[i915#6268]: https://gitlab.freedesktop.org/drm/intel/issues/6268
[i915#6301]: https://gitlab.freedesktop.org/drm/intel/issues/6301
[i915#6334]: https://gitlab.freedesktop.org/drm/intel/issues/6334
[i915#6335]: https://gitlab.freedesktop.org/drm/intel/issues/6335
[i915#6344]: https://gitlab.freedesktop.org/drm/intel/issues/6344
[i915#6403]: https://gitlab.freedesktop.org/drm/intel/issues/6403
[i915#6412]: https://gitlab.freedesktop.org/drm/intel/issues/6412
[i915#6433]: https://gitlab.freedesktop.org/drm/intel/issues/6433
[i915#6458]: https://gitlab.freedesktop.org/drm/intel/issues/6458
[i915#6463]: https://gitlab.freedesktop.org/drm/intel/issues/6463
[i915#6497]: https://gitlab.freedesktop.org/drm/intel/issues/6497
[i915#6524]: https://gitlab.freedesktop.org/drm/intel/issues/6524
[i915#658]: https://gitlab.freedesktop.org/drm/intel/issues/658
[i915#6590]: https://gitlab.freedesktop.org/drm/intel/issues/6590
[i915#6621]: https://gitlab.freedesktop.org/drm/intel/issues/6621
[i915#6934]: https://gitlab.freedesktop.org/drm/intel/issues/6934
[i915#6946]: https://gitlab.freedesktop.org/drm/intel/issues/6946
[i915#6987]: https://gitlab.freedesktop.org/drm/intel/issues/6987
[i915#716]: https://gitlab.freedesktop.org/drm/intel/issues/716
[i915#768]: https://gitlab.freedesktop.org/drm/intel/issues/768
[i915#79]: https://gitlab.freedesktop.org/drm/intel/issues/79
Build changes
-------------
* CI: CI-20190529 -> None
* IGT: IGT_7000 -> IGTPW_7917
* Piglit: piglit_4509 -> None
CI-20190529: 20190529
CI_DRM_12221: 473f3064abe6fbdd81fc696215a853ec44ed4b8f @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_7917: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/index.html
IGT_7000: 17292ab1e63802d8456670f606f8ad78082d09ee @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7917/index.html
[-- Attachment #2: Type: text/html, Size: 50780 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility
2022-10-04 9:41 ` Petri Latvala
@ 2022-10-06 2:30 ` Jake Freeland
0 siblings, 0 replies; 20+ messages in thread
From: Jake Freeland @ 2022-10-06 2:30 UTC (permalink / raw)
To: Petri Latvala; +Cc: igt-dev, Jake Freeland
[-- Attachment #1: Type: text/plain, Size: 27289 bytes --]
Hi Petri,
The oom_adjust_for_doom() function sets the process up for termination.
I had #ifdef'd the entire oom_adjust_for_doom() definition because
FreeBSD's procfs implementation does not have a oom_score_adj file for
process score adjustment. The block that you're mentioning sends the
SIGTERM to the process, artificially reproducing oom_score_adj().
I just submitted a new patch revision that moves the `raise(SIGTERM)` into
the oom_score_adj() function for FreeBSD. I have documented this behavior
in a comment to minimize confusion until FreeBSD has a fully featured
procfs.
Thank you,
Jake Freeland
On Tue, Oct 4, 2022 at 4:42 AM Petri Latvala <petri.latvala@intel.com>
wrote:
> On Wed, Sep 28, 2022 at 03:21:52PM -0500, Jake Freeland wrote:
> > FreeBSD's Linux compatbility layer, LinuxKPI, has introduced
> > modern drm drivers to the FreeBSD desktop. With drm drivers,
> > comes the need for drm testing. This patch allows a portion
> > of igt-gpu-tools to compile on FreeBSD
> >
> > Signed-off-by: Jake Freeland <jfree@freebsd.org>
> > ---
> > benchmarks/gem_exec_tracer.c | 4 ++
> > benchmarks/gem_syslatency.c | 6 ++
> > include/linux-uapi/sync_file.h | 5 ++
> > lib/i915/intel_memory_region.c | 4 ++
> > lib/i915/perf.c | 2 +
> > lib/igt_audio.c | 4 ++
> > lib/igt_aux.c | 2 +
> > lib/igt_aux.h | 6 +-
> > lib/igt_core.c | 8 ++-
> > lib/igt_core.h | 7 ++
> > lib/igt_debugfs.c | 2 +
> > lib/igt_device.c | 2 +
> > lib/igt_device_scan.c | 4 ++
> > lib/igt_eld.c | 4 ++
> > lib/igt_frame.c | 4 ++
> > lib/igt_freebsd.h | 121 +++++++++++++++++++++++++++++++++
> > lib/igt_kmod.h | 2 +
> > lib/igt_kms.c | 4 ++
> > lib/igt_os.c | 19 ++++++
> > lib/igt_perf.c | 2 +
> > lib/igt_perf.h | 4 ++
> > lib/igt_pm.c | 2 +
> > lib/igt_sysfs.c | 2 +
> > lib/tests/igt_exit_handler.c | 4 ++
> > lib/tests/igt_fork.c | 2 +-
> > lib/tests/igt_tests_common.h | 9 +++
> > runner/executor.c | 6 ++
> > runner/job_list.c | 5 ++
> > tests/i915/gem_close_race.c | 2 +
> > tests/i915/gem_mmap_gtt.c | 2 +-
> > tests/i915/gem_mmap_offset.c | 2 +-
> > tests/i915/i915_module_load.c | 2 +
> > tests/i915/i915_pm_backlight.c | 4 ++
> > tests/i915/i915_pm_rpm.c | 8 +++
> > tests/kms_content_protection.c | 2 +
> > tests/kms_flip.c | 4 ++
> > tests/kms_sysfs_edid_timing.c | 4 ++
> > tests/tools_test.c | 4 ++
> > tools/intel_gvtg_test.c | 4 ++
> > 39 files changed, 274 insertions(+), 10 deletions(-)
> > create mode 100644 lib/igt_freebsd.h
> >
> > diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
> > index e6973991..7e86473e 100644
> > --- a/benchmarks/gem_exec_tracer.c
> > +++ b/benchmarks/gem_exec_tracer.c
> > @@ -41,6 +41,10 @@
> > #include "intel_aub.h"
> > #include "intel_chipset.h"
> >
> > +#ifdef __FreeBSD__
> > +#include "igt_freebsd.h"
> > +#endif
> > +
> > static int (*libc_close)(int fd);
> > static int (*libc_ioctl)(int fd, unsigned long request, void *argp);
> >
> > diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
> > index 035ee934..dafc6ac0 100644
> > --- a/benchmarks/gem_syslatency.c
> > +++ b/benchmarks/gem_syslatency.c
> > @@ -42,12 +42,18 @@
> > #include <limits.h>
> > #include "drm.h"
> >
> > +#ifdef __linux__
> > #include <linux/unistd.h>
> > +#elif defined(__FreeBSD__)
> > +#include "igt_freebsd.h"
> > +#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/include/linux-uapi/sync_file.h
> b/include/linux-uapi/sync_file.h
> > index b4f2db00..270c1cbc 100644
> > --- a/include/linux-uapi/sync_file.h
> > +++ b/include/linux-uapi/sync_file.h
> > @@ -12,8 +12,13 @@
> > #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 "igt_freebsd.h"
> > +#endif
> >
> > /**
> > * struct sync_merge_data - data passed to merge ioctl
> > diff --git a/lib/i915/intel_memory_region.c
> b/lib/i915/intel_memory_region.c
> > index 568bace9..0a59f290 100644
> > --- a/lib/i915/intel_memory_region.c
> > +++ b/lib/i915/intel_memory_region.c
> > @@ -21,7 +21,11 @@
> > * IN THE SOFTWARE.
> > */
> >
> > +#ifdef __linux__
> > #include <linux/limits.h>
> > +#elif defined(__FreeBSD__)
> > +#include <limits.h>
> > +#endif
> > #include <signal.h>
> > #include <sys/ioctl.h>
> > #include <sys/time.h>
> > diff --git a/lib/i915/perf.c b/lib/i915/perf.c
> > index d88835ff..beda6b8a 100644
> > --- a/lib/i915/perf.c
> > +++ b/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/lib/igt_audio.c b/lib/igt_audio.c
> > index e0b1bafe..201a39c6 100644
> > --- a/lib/igt_audio.c
> > +++ b/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/lib/igt_aux.c b/lib/igt_aux.c
> > index edb53425..d7e2714f 100644
> > --- a/lib/igt_aux.c
> > +++ b/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"
> > diff --git a/lib/igt_aux.h b/lib/igt_aux.h
> > index c8d487b6..912f36c1 100644
> > --- a/lib/igt_aux.h
> > +++ b/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/lib/igt_core.c b/lib/igt_core.c
> > index e7425326..17d5e013 100644
> > --- a/lib/igt_core.c
> > +++ b/lib/igt_core.c
> > @@ -43,9 +43,7 @@
> > #include <unistd.h>
> > #include <sys/wait.h>
> > #include <sys/types.h>
> > -#ifdef __linux__
> > #include <sys/syscall.h>
> > -#endif
> > #include <pthread.h>
> > #include <sys/utsname.h>
> > #include <termios.h>
> > @@ -786,6 +784,7 @@ static void print_usage(const char *help_str, bool
> output_on_stderr)
> >
> > static void oom_adjust_for_doom(void)
> > {
> > +#ifdef __linux__
> > int fd;
> > const char always_kill[] = "1000";
> >
> > @@ -793,7 +792,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
> > }
> >
> > /**
> > @@ -2224,6 +2223,9 @@ bool __igt_fork_helper(struct igt_helper_process
> *proc)
> > case 0:
> > reset_helper_process_list();
> > oom_adjust_for_doom();
> > +#ifdef __FreeBSD__
> > + raise(SIGTERM);
> > +#endif
>
> Can't say I understand why this is added. Is this a /* TODO */ of some
> description?
>
>
> --
> Petri Latvala
>
>
>
> >
> > return true;
> > default:
> > diff --git a/lib/igt_core.h b/lib/igt_core.h
> > index aa98e8ed..18e1009d 100644
> > --- a/lib/igt_core.h
> > +++ b/lib/igt_core.h
> > @@ -31,7 +31,11 @@
> > #define IGT_CORE_H
> >
> > #include <assert.h>
> > +#ifdef __linux__
> > #include <byteswap.h>
> > +#elif defined(__FreeBSD__)
> > +#include <sys/endian.h>
> > +#endif
> > #include <setjmp.h>
> > #include <stdbool.h>
> > #include <stdint.h>
> > @@ -47,6 +51,9 @@
> > #define IGT_LOG_DOMAIN (NULL)
> > #endif
> >
> > +#ifdef __FreeBSD__
> > +#include "igt_freebsd.h"
> > +#endif
> >
> > #ifndef STATIC_ANALYSIS_BUILD
> > #if defined(__clang_analyzer__) || defined(__COVERITY__) ||
> defined(__KLOCWORK__)
> > diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> > index a56688a5..fa1e3b69 100644
> > --- a/lib/igt_debugfs.c
> > +++ b/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>
> > diff --git a/lib/igt_device.c b/lib/igt_device.c
> > index fddfba72..49b77122 100644
> > --- a/lib/igt_device.c
> > +++ b/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/lib/igt_device_scan.c b/lib/igt_device_scan.c
> > index eb6b45b8..6a921d52 100644
> > --- a/lib/igt_device_scan.c
> > +++ b/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/lib/igt_eld.c b/lib/igt_eld.c
> > index ef6625df..e05ad6de 100644
> > --- a/lib/igt_eld.c
> > +++ b/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/lib/igt_frame.c b/lib/igt_frame.c
> > index 45523a79..ab74e678 100644
> > --- a/lib/igt_frame.c
> > +++ b/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/lib/igt_freebsd.h b/lib/igt_freebsd.h
> > new file mode 100644
> > index 00000000..81ba5c01
> > --- /dev/null
> > +++ b/lib/igt_freebsd.h
> > @@ -0,0 +1,121 @@
> > +/*
> > + * SPDX-License-Identifier: MIT
> > + *
> > + * Copyright (c) 2022, Jake Freeland <jfree@FreeBSD.org>
> > + *
> > + * 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.
> > + */
> > +
> > +#if !defined(IGT_FREEBSD_H) && defined(__FreeBSD__)
> > +#define IGT_FREEBSD_H
> > +
> > +#include <sys/errno.h>
> > +#include <sys/mman.h>
> > +#include <sys/mount.h>
> > +#include <sys/sched.h>
> > +#include <sys/types.h>
> > +#include <sys/watchdog.h>
> > +
> > +#include <pthread.h>
> > +#include <setjmp.h>
> > +#include <signal.h>
> > +#include <unistd.h>
> > +
> > +/*
> > + * Proper substitutions:
> > + * The following macros replace Linux-specific functions
> > + * and macros with their FreeBSD equivalents.
> > + */
> > +
> > +#define __s32 int32_t
> > +#define __u32 uint32_t
> > +#define __u64 uint64_t
> > +
> > +#define sighandler_t sig_t
> > +#define ino64_t ino_t
> > +
> > +#define jmp_buf sigjmp_buf
> > +
> > +#define PTRACE_TRACEME PT_TRACE_ME
> > +#define PTRACE_ATTACH PT_ATTACH
> > +#define PTRACE_PEEKDATA PT_READ_D
> > +#define PTRACE_POKEDATA PT_WRITE_D
> > +#define PTRACE_DETACH PT_DETACH
> > +
> > +#define I2C_RDWR I2CRDWR
> > +#define I2C_M_RD IIC_M_RD
> > +#define i2c_msg iic_msg
> > +#define i2c_rdwr_ioctl_data iic_rdwr_data
> > +
> > +#define _IOC_TYPE(nr) (((nr) >> 8) & 255)
> > +
> > +#define SYS_getdents64 SYS_freebsd11_getdents
> > +
> > +#define mount(src, dest, fstype, flags, data) \
> > + mount(fstype, dest, flags, data)
> > +
> > +/*
> > + * Improper substitutions:
> > + * The following macros are temporary replacements for functions
> > + * and macros that exist on Linux and do not exist on FreeBSD.
> > + */
> > +
> > +#define ETIME ETIMEDOUT
> > +
> > +#define MAP_POPULATE MAP_PREFAULT_READ
> > +
> > +#define MADV_HUGEPAGE MADV_SEQUENTIAL
> > +#define MADV_DONTFORK MADV_NOSYNC
> > +
> > +#define WDIOC_KEEPALIVE WDIOCPATPAT
> > +
> > +#define SCHED_RESET_ON_FORK 0
> > +#define SCHED_IDLE SCHED_OTHER
> > +
> > +#define gettid() getpid()
> > +
> > +#define pthread_sigqueue(pid, signo, value) \
> > + sigqueue(pid, signo, value)
> > +
> > +#define signalfd(fd, mask, flags) -ENOSYS
> > +#define timerfd_create(c, f) -ENOSYS
> > +#define timerfd_settime(fd, f, n, o) -ENOSYS
> > +
> > +/*
> > + * Macro conflict resolution.
> > + */
> > +
> > +#undef ALIGN
> > +#undef PAGE_SIZE
> > +
> > +struct signalfd_siginfo {
> > + uint32_t ssi_signo;
> > + uint32_t ssi_pid;
> > +};
> > +
> > +struct kmod_module {
> > + size_t size;
> > +};
> > +
> > +typedef struct {
> > + char state;
> > +} proc_t;
> > +
> > +#endif /* IGT_FREEBSD_H */
> > diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
> > index f98dd29f..6596092b 100644
> > --- a/lib/igt_kmod.h
> > +++ b/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/lib/igt_kms.c b/lib/igt_kms.c
> > index 665594aa..532a3aa8 100644
> > --- a/lib/igt_kms.c
> > +++ b/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/lib/igt_os.c b/lib/igt_os.c
> > index bdd5d933..bb6994e1 100644
> > --- a/lib/igt_os.c
> > +++ b/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__)
> > + 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__)
> > + 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/lib/igt_perf.c b/lib/igt_perf.c
> > index b743859f..11c91c5f 100644
> > --- a/lib/igt_perf.c
> > +++ b/lib/igt_perf.c
> > @@ -4,8 +4,10 @@
> > #include <stdlib.h>
> > #include <string.h>
> > #include <sys/stat.h>
> > +#ifdef __linux__
> > #include <sys/sysinfo.h>
> > #include <sys/sysmacros.h>
> > +#endif
> > #include <time.h>
> > #include <unistd.h>
> >
> > diff --git a/lib/igt_perf.h b/lib/igt_perf.h
> > index a8328c70..0cd91386 100644
> > --- a/lib/igt_perf.h
> > +++ b/lib/igt_perf.h
> > @@ -27,10 +27,13 @@
> >
> > #include <stdint.h>
> >
> > +#ifdef __linux__
> > #include <linux/perf_event.h>
> > +#endif
> >
> > #include "igt_gt.h"
> >
> > +#ifdef __linux__
> > static inline int
> > perf_event_open(struct perf_event_attr *attr,
> > pid_t pid,
> > @@ -50,6 +53,7 @@ perf_event_open(struct perf_event_attr *attr,
> > attr->size = sizeof(*attr);
> > return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd,
> flags);
> > }
> > +#endif /* __linux__ */
> >
> > uint64_t igt_perf_type_id(const char *device);
> > int igt_perf_open(uint64_t type, uint64_t config);
> > diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> > index 312288d0..1e6e9ed3 100644
> > --- a/lib/igt_pm.c
> > +++ b/lib/igt_pm.c
> > @@ -33,7 +33,9 @@
> > #include <string.h>
> > #include <unistd.h>
> > #include <sys/stat.h>
> > +#ifdef __linux__
> > #include <sys/sysmacros.h>
> > +#endif
> > #include <sys/types.h>
> > #include <dirent.h>
> >
> > diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
> > index 9c307694..a913be4c 100644
> > --- a/lib/igt_sysfs.c
> > +++ b/lib/igt_sysfs.c
> > @@ -24,7 +24,9 @@
> >
> > #include <inttypes.h>
> > #include <sys/stat.h>
> > +#ifdef __linux__
> > #include <sys/sysmacros.h>
> > +#endif
> > #include <sys/mount.h>
> > #include <errno.h>
> > #include <stdarg.h>
> > diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
> > index 892a7f14..d2381944 100644
> > --- a/lib/tests/igt_exit_handler.c
> > +++ b/lib/tests/igt_exit_handler.c
> > @@ -125,5 +125,9 @@ int main(int argc, char **argv)
> > internal_assert_wexited(status, IGT_EXIT_SKIP);
> >
> > status = testfunc(SIG);
> > +#ifdef __linux__
> > internal_assert_wsignaled(status, SIGTERM);
> > +#elif defined(__FreeBSD__)
> > + internal_assert(status == 0);
> > +#endif
> > }
> > diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
> > index d19d0945..c7193b06 100644
> > --- a/lib/tests/igt_fork.c
> > +++ b/lib/tests/igt_fork.c
> > @@ -109,7 +109,7 @@ __noreturn static void igt_fork_timeout_leak(void)
> > __noreturn static void subtest_leak(void)
> > {
> > pid_t *children =
> > - mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
> > + mmap(0, 4096, PROT_WRITE | PROT_READ, MAP_SHARED |
> MAP_ANON, -1, 0);
> > const int num_children = 4096 / sizeof(*children);
> >
> > igt_subtest_init(fake_argc, fake_argv);
> > diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
> > index 058f6265..e8183897 100644
> > --- a/lib/tests/igt_tests_common.h
> > +++ b/lib/tests/igt_tests_common.h
> > @@ -48,8 +48,17 @@ static inline void internal_assert_wexited(int
> wstatus, int exitcode)
> >
> > static inline void internal_assert_wsignaled(int wstatus, int signal)
> > {
> > +#ifdef __linux__
> > internal_assert(WIFSIGNALED(wstatus) &&
> > WTERMSIG(wstatus) == signal);
> > +#elif defined(__FreeBSD__)
> > + if (WIFSIGNALED(wstatus))
> > + internal_assert(WTERMSIG(wstatus) == signal);
> > + else if (WIFEXITED(wstatus))
> > + internal_assert(WEXITSTATUS(wstatus) == signal + 128);
> > + else
> > + internal_assert(0);
> > +#endif
> > }
> >
> > static inline void internal_assert_not_wsignaled(int wstatus)
> > diff --git a/runner/executor.c b/runner/executor.c
> > index 964d0063..c54072cf 100644
> > --- a/runner/executor.c
> > +++ b/runner/executor.c
> > @@ -2,7 +2,9 @@
> > #include <errno.h>
> > #include <fcntl.h>
> > #include <glib.h>
> > +#ifdef __linux__
> > #include <linux/watchdog.h>
> > +#endif
> > #if HAVE_OPING
> > #include <oping.h>
> > #endif
> > @@ -33,6 +35,10 @@
> > #define KMSG_HEADER "[IGT] "
> > #define KMSG_WARN 4
> >
> > +#ifdef __FreeBSD__
> > +#include <sys/watchdog.h>
> > +#endif
> > +
> > static struct {
> > int *fds;
> > size_t num_dogs;
> > diff --git a/runner/job_list.c b/runner/job_list.c
> > index 520a98da..6bfa7162 100644
> > --- a/runner/job_list.c
> > +++ b/runner/job_list.c
> > @@ -1,7 +1,12 @@
> > #include <ctype.h>
> > #include <errno.h>
> > #include <fcntl.h>
> > +#ifdef __linux__
> > #include <linux/limits.h>
> > +#elif defined(__FreeBSD__)
> > +#include <sys/wait.h>
> > +#include <limits.h>
> > +#endif
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <string.h>
> > diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
> > index 938fde8f..42fe1657 100644
> > --- a/tests/i915/gem_close_race.c
> > +++ b/tests/i915/gem_close_race.c
> > @@ -61,7 +61,9 @@ static bool has_softpin;
> > static uint64_t exec_addr;
> > static uint64_t data_addr;
> >
> > +#ifdef __linux__
> > #define sigev_notify_thread_id _sigev_un._tid
> > +#endif
> >
> > static void selfcopy(int fd, uint32_t ctx, uint32_t handle, int loops)
> > {
> > diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
> > index e39b9047..4f05eb18 100644
> > --- a/tests/i915/gem_mmap_gtt.c
> > +++ b/tests/i915/gem_mmap_gtt.c
> > @@ -566,7 +566,7 @@ test_ptrace(int fd)
> > for (int i = 0; i < sz / sizeof(long); i++) {
> > long ret;
> >
> > - ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i);
> > + ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i, NULL);
> > igt_assert_eq_u64(ret, CC);
> > cpy[i] = ret;
> >
> > diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
> > index 7e8c02d1..fc4245f6 100644
> > --- a/tests/i915/gem_mmap_offset.c
> > +++ b/tests/i915/gem_mmap_offset.c
> > @@ -520,7 +520,7 @@ static void test_ptrace(int i915)
> > for (int i = 0; i < SZ / sizeof(long);
> i++) {
> > long ret;
> >
> > - ret = ptrace(PTRACE_PEEKDATA, pid,
> ptr + i);
> > + ret = ptrace(PTRACE_PEEKDATA, pid,
> ptr + i, NULL);
> > igt_assert_eq_u64(ret, CC);
> > cpy[i] = ret;
> >
> > diff --git a/tests/i915/i915_module_load.c
> b/tests/i915/i915_module_load.c
> > index 4c72157c..9bec4c18 100644
> > --- a/tests/i915/i915_module_load.c
> > +++ b/tests/i915/i915_module_load.c
> > @@ -23,7 +23,9 @@
> > #include "igt.h"
> > #include <dirent.h>
> > #include <sys/utsname.h>
> > +#ifdef __linux__
> > #include <linux/limits.h>
> > +#endif
> > #include <signal.h>
> > #include <libgen.h>
> > #include <signal.h>
> > diff --git a/tests/i915/i915_pm_backlight.c
> b/tests/i915/i915_pm_backlight.c
> > index cafae7f7..c520cf20 100644
> > --- a/tests/i915/i915_pm_backlight.c
> > +++ b/tests/i915/i915_pm_backlight.c
> > @@ -46,6 +46,10 @@ struct context {
> > #define FADESTEPS 10
> > #define FADESPEED 100 /* milliseconds between steps */
> >
> > +#ifdef __FreeBSD__
> > +#include <libgen.h>
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
> >
> > static int backlight_read(int *result, const char *fname)
> > diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
> > index e95875dc..761e76f9 100644
> > --- a/tests/i915/i915_pm_rpm.c
> > +++ b/tests/i915/i915_pm_rpm.c
> > @@ -40,8 +40,10 @@
> > #include <sys/mman.h>
> > #include <sys/types.h>
> > #include <sys/stat.h>
> > +#ifdef __linux__
> > #include <linux/i2c.h>
> > #include <linux/i2c-dev.h>
> > +#endif
> >
> > #include <drm.h>
> >
> > @@ -54,6 +56,12 @@
> > #include "igt_device.h"
> > #include "igt_edid.h"
> >
> > +#ifdef __FreeBSD__
> > +#include <limits.h>
> > +#include <dev/iicbus/iic.h>
> > +#define addr slave
> > +#endif
> > +
> > #define MSR_PC8_RES 0x630
> > #define MSR_PC9_RES 0x631
> > #define MSR_PC10_RES 0x632
> > diff --git a/tests/kms_content_protection.c
> b/tests/kms_content_protection.c
> > index 3041f1cd..e0e5af78 100644
> > --- a/tests/kms_content_protection.c
> > +++ b/tests/kms_content_protection.c
> > @@ -24,7 +24,9 @@
> >
> > #include <poll.h>
> > #include <fcntl.h>
> > +#ifdef __linux__
> > #include <sys/epoll.h>
> > +#endif
> > #include <sys/stat.h>
> > #include <libudev.h>
> > #include "igt.h"
> > diff --git a/tests/kms_flip.c b/tests/kms_flip.c
> > index 0567edea..1127e418 100755
> > --- a/tests/kms_flip.c
> > +++ b/tests/kms_flip.c
> > @@ -45,6 +45,10 @@
> > #include "i915/gem_create.h"
> > #include "igt_stats.h"
> >
> > +#ifdef __FreeBSD__
> > +#include <sys/consio.h>
> > +#endif
> > +
> > #define TEST_DPMS (1 << 0)
> >
> > #define TEST_PAN (1 << 3)
> > diff --git a/tests/kms_sysfs_edid_timing.c
> b/tests/kms_sysfs_edid_timing.c
> > index 77521108..cd980c6a 100644
> > --- a/tests/kms_sysfs_edid_timing.c
> > +++ b/tests/kms_sysfs_edid_timing.c
> > @@ -26,6 +26,10 @@
> > #include <fcntl.h>
> > #include <sys/stat.h>
> >
> > +#ifdef __FreeBSD__
> > +#include <limits.h>
> > +#endif
> > +
> > #define THRESHOLD_PER_CONNECTOR 150
> > #define THRESHOLD_PER_CONNECTOR_MEAN 140
> > #define THRESHOLD_ALL_CONNECTORS_MEAN 100
> > diff --git a/tests/tools_test.c b/tests/tools_test.c
> > index 237f0433..89a19d11 100644
> > --- a/tests/tools_test.c
> > +++ b/tests/tools_test.c
> > @@ -28,7 +28,11 @@
> > #include <fcntl.h>
> > #include <libgen.h>
> > #include <unistd.h>
> > +#ifdef __linux__
> > #include <linux/limits.h>
> > +#elif defined(__FreeBSD__)
> > +#include <limits.h>
> > +#endif
> >
> > #define TOOLS "../tools/"
> >
> > diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c
> > index ad5ee6a6..3e53c6d9 100644
> > --- a/tools/intel_gvtg_test.c
> > +++ b/tools/intel_gvtg_test.c
> > @@ -55,6 +55,10 @@
> > #include <limits.h>
> > #include <dirent.h>
> >
> > +#ifdef __FreeBSD__
> > +#include <sys/wait.h>
> > +#endif
> > +
> > #define RANDOM(x) (rand() % x)
> >
> >
> > --
> > 2.37.3
> >
>
[-- Attachment #2: Type: text/html, Size: 35853 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility
@ 2022-10-06 1:09 Jake Freeland
0 siblings, 0 replies; 20+ messages in thread
From: Jake Freeland @ 2022-10-06 1:09 UTC (permalink / raw)
To: igt-dev; +Cc: Jake Freeland
FreeBSD's Linux compatbility layer, LinuxKPI, has introduced
modern drm drivers to the FreeBSD desktop. With drm drivers,
comes the need for drm testing. This patch allows a portion
of igt-gpu-tools to compile on FreeBSD
Signed-off-by: Jake Freeland <jfree@freebsd.org>
---
benchmarks/gem_exec_tracer.c | 4 ++
benchmarks/gem_syslatency.c | 6 ++
include/linux-uapi/sync_file.h | 5 ++
lib/i915/intel_memory_region.c | 4 ++
lib/i915/perf.c | 2 +
lib/igt_audio.c | 4 ++
lib/igt_aux.c | 2 +
lib/igt_aux.h | 6 +-
lib/igt_core.c | 11 ++-
lib/igt_core.h | 8 +++
lib/igt_debugfs.c | 2 +
lib/igt_device.c | 2 +
lib/igt_device_scan.c | 4 ++
lib/igt_eld.c | 4 ++
lib/igt_frame.c | 4 ++
lib/igt_freebsd.h | 121 +++++++++++++++++++++++++++++++++
lib/igt_kmod.h | 2 +
lib/igt_kms.c | 4 ++
lib/igt_os.c | 19 ++++++
lib/igt_perf.c | 2 +
lib/igt_perf.h | 4 ++
lib/igt_pm.c | 2 +
lib/igt_sysfs.c | 2 +
lib/tests/igt_exit_handler.c | 4 ++
lib/tests/igt_fork.c | 2 +-
lib/tests/igt_tests_common.h | 9 +++
runner/executor.c | 6 ++
runner/job_list.c | 5 ++
tests/i915/gem_close_race.c | 2 +
tests/i915/gem_mmap_gtt.c | 2 +-
tests/i915/gem_mmap_offset.c | 2 +-
tests/i915/i915_module_load.c | 2 +
tests/i915/i915_pm_backlight.c | 4 ++
tests/i915/i915_pm_rpm.c | 8 +++
tests/kms_content_protection.c | 2 +
tests/kms_flip.c | 4 ++
tests/kms_sysfs_edid_timing.c | 4 ++
tests/tools_test.c | 4 ++
tools/intel_gvtg_test.c | 4 ++
39 files changed, 278 insertions(+), 10 deletions(-)
create mode 100644 lib/igt_freebsd.h
diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
index e6973991..7e86473e 100644
--- a/benchmarks/gem_exec_tracer.c
+++ b/benchmarks/gem_exec_tracer.c
@@ -41,6 +41,10 @@
#include "intel_aub.h"
#include "intel_chipset.h"
+#ifdef __FreeBSD__
+#include "igt_freebsd.h"
+#endif
+
static int (*libc_close)(int fd);
static int (*libc_ioctl)(int fd, unsigned long request, void *argp);
diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
index 035ee934..dafc6ac0 100644
--- a/benchmarks/gem_syslatency.c
+++ b/benchmarks/gem_syslatency.c
@@ -42,12 +42,18 @@
#include <limits.h>
#include "drm.h"
+#ifdef __linux__
#include <linux/unistd.h>
+#elif defined(__FreeBSD__)
+#include "igt_freebsd.h"
+#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/include/linux-uapi/sync_file.h b/include/linux-uapi/sync_file.h
index b4f2db00..270c1cbc 100644
--- a/include/linux-uapi/sync_file.h
+++ b/include/linux-uapi/sync_file.h
@@ -12,8 +12,13 @@
#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 "igt_freebsd.h"
+#endif
/**
* struct sync_merge_data - data passed to merge ioctl
diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
index 568bace9..0a59f290 100644
--- a/lib/i915/intel_memory_region.c
+++ b/lib/i915/intel_memory_region.c
@@ -21,7 +21,11 @@
* IN THE SOFTWARE.
*/
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <limits.h>
+#endif
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/time.h>
diff --git a/lib/i915/perf.c b/lib/i915/perf.c
index d88835ff..beda6b8a 100644
--- a/lib/i915/perf.c
+++ b/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/lib/igt_audio.c b/lib/igt_audio.c
index e0b1bafe..201a39c6 100644
--- a/lib/igt_audio.c
+++ b/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/lib/igt_aux.c b/lib/igt_aux.c
index edb53425..d7e2714f 100644
--- a/lib/igt_aux.c
+++ b/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"
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index c8d487b6..912f36c1 100644
--- a/lib/igt_aux.h
+++ b/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/lib/igt_core.c b/lib/igt_core.c
index e7425326..b4b8877f 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -43,9 +43,7 @@
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
-#ifdef __linux__
#include <sys/syscall.h>
-#endif
#include <pthread.h>
#include <sys/utsname.h>
#include <termios.h>
@@ -786,6 +784,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
static void oom_adjust_for_doom(void)
{
+#ifdef __linux__
int fd;
const char always_kill[] = "1000";
@@ -793,7 +792,13 @@ 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);
-
+#elif defined(__FreeBSD__)
+ /*
+ * oom_score_adj not present in FreeBSD's linprocfs.
+ * Stop process directly instead.
+ */
+ raise(SIGTERM);
+#endif
}
/**
diff --git a/lib/igt_core.h b/lib/igt_core.h
index aa98e8ed..cc382497 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -31,7 +31,11 @@
#define IGT_CORE_H
#include <assert.h>
+#ifdef __linux__
#include <byteswap.h>
+#elif defined(__FreeBSD__)
+#include <sys/endian.h>
+#endif
#include <setjmp.h>
#include <stdbool.h>
#include <stdint.h>
@@ -43,6 +47,10 @@
#include <getopt.h>
#include <unistd.h>
+#ifdef __FreeBSD__
+#include "igt_freebsd.h"
+#endif
+
#ifndef IGT_LOG_DOMAIN
#define IGT_LOG_DOMAIN (NULL)
#endif
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index a56688a5..fa1e3b69 100644
--- a/lib/igt_debugfs.c
+++ b/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>
diff --git a/lib/igt_device.c b/lib/igt_device.c
index fddfba72..49b77122 100644
--- a/lib/igt_device.c
+++ b/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/lib/igt_device_scan.c b/lib/igt_device_scan.c
index eb6b45b8..6a921d52 100644
--- a/lib/igt_device_scan.c
+++ b/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/lib/igt_eld.c b/lib/igt_eld.c
index ef6625df..e05ad6de 100644
--- a/lib/igt_eld.c
+++ b/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/lib/igt_frame.c b/lib/igt_frame.c
index 45523a79..ab74e678 100644
--- a/lib/igt_frame.c
+++ b/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/lib/igt_freebsd.h b/lib/igt_freebsd.h
new file mode 100644
index 00000000..81ba5c01
--- /dev/null
+++ b/lib/igt_freebsd.h
@@ -0,0 +1,121 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (c) 2022, Jake Freeland <jfree@FreeBSD.org>
+ *
+ * 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.
+ */
+
+#if !defined(IGT_FREEBSD_H) && defined(__FreeBSD__)
+#define IGT_FREEBSD_H
+
+#include <sys/errno.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/sched.h>
+#include <sys/types.h>
+#include <sys/watchdog.h>
+
+#include <pthread.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <unistd.h>
+
+/*
+ * Proper substitutions:
+ * The following macros replace Linux-specific functions
+ * and macros with their FreeBSD equivalents.
+ */
+
+#define __s32 int32_t
+#define __u32 uint32_t
+#define __u64 uint64_t
+
+#define sighandler_t sig_t
+#define ino64_t ino_t
+
+#define jmp_buf sigjmp_buf
+
+#define PTRACE_TRACEME PT_TRACE_ME
+#define PTRACE_ATTACH PT_ATTACH
+#define PTRACE_PEEKDATA PT_READ_D
+#define PTRACE_POKEDATA PT_WRITE_D
+#define PTRACE_DETACH PT_DETACH
+
+#define I2C_RDWR I2CRDWR
+#define I2C_M_RD IIC_M_RD
+#define i2c_msg iic_msg
+#define i2c_rdwr_ioctl_data iic_rdwr_data
+
+#define _IOC_TYPE(nr) (((nr) >> 8) & 255)
+
+#define SYS_getdents64 SYS_freebsd11_getdents
+
+#define mount(src, dest, fstype, flags, data) \
+ mount(fstype, dest, flags, data)
+
+/*
+ * Improper substitutions:
+ * The following macros are temporary replacements for functions
+ * and macros that exist on Linux and do not exist on FreeBSD.
+ */
+
+#define ETIME ETIMEDOUT
+
+#define MAP_POPULATE MAP_PREFAULT_READ
+
+#define MADV_HUGEPAGE MADV_SEQUENTIAL
+#define MADV_DONTFORK MADV_NOSYNC
+
+#define WDIOC_KEEPALIVE WDIOCPATPAT
+
+#define SCHED_RESET_ON_FORK 0
+#define SCHED_IDLE SCHED_OTHER
+
+#define gettid() getpid()
+
+#define pthread_sigqueue(pid, signo, value) \
+ sigqueue(pid, signo, value)
+
+#define signalfd(fd, mask, flags) -ENOSYS
+#define timerfd_create(c, f) -ENOSYS
+#define timerfd_settime(fd, f, n, o) -ENOSYS
+
+/*
+ * Macro conflict resolution.
+ */
+
+#undef ALIGN
+#undef PAGE_SIZE
+
+struct signalfd_siginfo {
+ uint32_t ssi_signo;
+ uint32_t ssi_pid;
+};
+
+struct kmod_module {
+ size_t size;
+};
+
+typedef struct {
+ char state;
+} proc_t;
+
+#endif /* IGT_FREEBSD_H */
diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
index f98dd29f..6596092b 100644
--- a/lib/igt_kmod.h
+++ b/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/lib/igt_kms.c b/lib/igt_kms.c
index 665594aa..532a3aa8 100644
--- a/lib/igt_kms.c
+++ b/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/lib/igt_os.c b/lib/igt_os.c
index bdd5d933..bb6994e1 100644
--- a/lib/igt_os.c
+++ b/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__)
+ 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__)
+ 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/lib/igt_perf.c b/lib/igt_perf.c
index b743859f..11c91c5f 100644
--- a/lib/igt_perf.c
+++ b/lib/igt_perf.c
@@ -4,8 +4,10 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysinfo.h>
#include <sys/sysmacros.h>
+#endif
#include <time.h>
#include <unistd.h>
diff --git a/lib/igt_perf.h b/lib/igt_perf.h
index a8328c70..0cd91386 100644
--- a/lib/igt_perf.h
+++ b/lib/igt_perf.h
@@ -27,10 +27,13 @@
#include <stdint.h>
+#ifdef __linux__
#include <linux/perf_event.h>
+#endif
#include "igt_gt.h"
+#ifdef __linux__
static inline int
perf_event_open(struct perf_event_attr *attr,
pid_t pid,
@@ -50,6 +53,7 @@ perf_event_open(struct perf_event_attr *attr,
attr->size = sizeof(*attr);
return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);
}
+#endif /* __linux__ */
uint64_t igt_perf_type_id(const char *device);
int igt_perf_open(uint64_t type, uint64_t config);
diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 312288d0..1e6e9ed3 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,7 +33,9 @@
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysmacros.h>
+#endif
#include <sys/types.h>
#include <dirent.h>
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 9c307694..a913be4c 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -24,7 +24,9 @@
#include <inttypes.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysmacros.h>
+#endif
#include <sys/mount.h>
#include <errno.h>
#include <stdarg.h>
diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
index 892a7f14..d2381944 100644
--- a/lib/tests/igt_exit_handler.c
+++ b/lib/tests/igt_exit_handler.c
@@ -125,5 +125,9 @@ int main(int argc, char **argv)
internal_assert_wexited(status, IGT_EXIT_SKIP);
status = testfunc(SIG);
+#ifdef __linux__
internal_assert_wsignaled(status, SIGTERM);
+#elif defined(__FreeBSD__)
+ internal_assert(status == 0);
+#endif
}
diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
index d19d0945..c7193b06 100644
--- a/lib/tests/igt_fork.c
+++ b/lib/tests/igt_fork.c
@@ -109,7 +109,7 @@ __noreturn static void igt_fork_timeout_leak(void)
__noreturn static void subtest_leak(void)
{
pid_t *children =
- mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+ mmap(0, 4096, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANON, -1, 0);
const int num_children = 4096 / sizeof(*children);
igt_subtest_init(fake_argc, fake_argv);
diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
index 058f6265..e8183897 100644
--- a/lib/tests/igt_tests_common.h
+++ b/lib/tests/igt_tests_common.h
@@ -48,8 +48,17 @@ static inline void internal_assert_wexited(int wstatus, int exitcode)
static inline void internal_assert_wsignaled(int wstatus, int signal)
{
+#ifdef __linux__
internal_assert(WIFSIGNALED(wstatus) &&
WTERMSIG(wstatus) == signal);
+#elif defined(__FreeBSD__)
+ if (WIFSIGNALED(wstatus))
+ internal_assert(WTERMSIG(wstatus) == signal);
+ else if (WIFEXITED(wstatus))
+ internal_assert(WEXITSTATUS(wstatus) == signal + 128);
+ else
+ internal_assert(0);
+#endif
}
static inline void internal_assert_not_wsignaled(int wstatus)
diff --git a/runner/executor.c b/runner/executor.c
index 964d0063..c54072cf 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -2,7 +2,9 @@
#include <errno.h>
#include <fcntl.h>
#include <glib.h>
+#ifdef __linux__
#include <linux/watchdog.h>
+#endif
#if HAVE_OPING
#include <oping.h>
#endif
@@ -33,6 +35,10 @@
#define KMSG_HEADER "[IGT] "
#define KMSG_WARN 4
+#ifdef __FreeBSD__
+#include <sys/watchdog.h>
+#endif
+
static struct {
int *fds;
size_t num_dogs;
diff --git a/runner/job_list.c b/runner/job_list.c
index 520a98da..6bfa7162 100644
--- a/runner/job_list.c
+++ b/runner/job_list.c
@@ -1,7 +1,12 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <sys/wait.h>
+#include <limits.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
index 938fde8f..42fe1657 100644
--- a/tests/i915/gem_close_race.c
+++ b/tests/i915/gem_close_race.c
@@ -61,7 +61,9 @@ static bool has_softpin;
static uint64_t exec_addr;
static uint64_t data_addr;
+#ifdef __linux__
#define sigev_notify_thread_id _sigev_un._tid
+#endif
static void selfcopy(int fd, uint32_t ctx, uint32_t handle, int loops)
{
diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
index e39b9047..4f05eb18 100644
--- a/tests/i915/gem_mmap_gtt.c
+++ b/tests/i915/gem_mmap_gtt.c
@@ -566,7 +566,7 @@ test_ptrace(int fd)
for (int i = 0; i < sz / sizeof(long); i++) {
long ret;
- ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i);
+ ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i, NULL);
igt_assert_eq_u64(ret, CC);
cpy[i] = ret;
diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
index 7e8c02d1..fc4245f6 100644
--- a/tests/i915/gem_mmap_offset.c
+++ b/tests/i915/gem_mmap_offset.c
@@ -520,7 +520,7 @@ static void test_ptrace(int i915)
for (int i = 0; i < SZ / sizeof(long); i++) {
long ret;
- ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i);
+ ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i, NULL);
igt_assert_eq_u64(ret, CC);
cpy[i] = ret;
diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c
index 4c72157c..9bec4c18 100644
--- a/tests/i915/i915_module_load.c
+++ b/tests/i915/i915_module_load.c
@@ -23,7 +23,9 @@
#include "igt.h"
#include <dirent.h>
#include <sys/utsname.h>
+#ifdef __linux__
#include <linux/limits.h>
+#endif
#include <signal.h>
#include <libgen.h>
#include <signal.h>
diff --git a/tests/i915/i915_pm_backlight.c b/tests/i915/i915_pm_backlight.c
index cafae7f7..c520cf20 100644
--- a/tests/i915/i915_pm_backlight.c
+++ b/tests/i915/i915_pm_backlight.c
@@ -46,6 +46,10 @@ struct context {
#define FADESTEPS 10
#define FADESPEED 100 /* milliseconds between steps */
+#ifdef __FreeBSD__
+#include <libgen.h>
+#endif
+
IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
static int backlight_read(int *result, const char *fname)
diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
index e95875dc..761e76f9 100644
--- a/tests/i915/i915_pm_rpm.c
+++ b/tests/i915/i915_pm_rpm.c
@@ -40,8 +40,10 @@
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
+#endif
#include <drm.h>
@@ -54,6 +56,12 @@
#include "igt_device.h"
#include "igt_edid.h"
+#ifdef __FreeBSD__
+#include <limits.h>
+#include <dev/iicbus/iic.h>
+#define addr slave
+#endif
+
#define MSR_PC8_RES 0x630
#define MSR_PC9_RES 0x631
#define MSR_PC10_RES 0x632
diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
index 3041f1cd..e0e5af78 100644
--- a/tests/kms_content_protection.c
+++ b/tests/kms_content_protection.c
@@ -24,7 +24,9 @@
#include <poll.h>
#include <fcntl.h>
+#ifdef __linux__
#include <sys/epoll.h>
+#endif
#include <sys/stat.h>
#include <libudev.h>
#include "igt.h"
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 0567edea..1127e418 100755
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -45,6 +45,10 @@
#include "i915/gem_create.h"
#include "igt_stats.h"
+#ifdef __FreeBSD__
+#include <sys/consio.h>
+#endif
+
#define TEST_DPMS (1 << 0)
#define TEST_PAN (1 << 3)
diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
index 77521108..cd980c6a 100644
--- a/tests/kms_sysfs_edid_timing.c
+++ b/tests/kms_sysfs_edid_timing.c
@@ -26,6 +26,10 @@
#include <fcntl.h>
#include <sys/stat.h>
+#ifdef __FreeBSD__
+#include <limits.h>
+#endif
+
#define THRESHOLD_PER_CONNECTOR 150
#define THRESHOLD_PER_CONNECTOR_MEAN 140
#define THRESHOLD_ALL_CONNECTORS_MEAN 100
diff --git a/tests/tools_test.c b/tests/tools_test.c
index 237f0433..89a19d11 100644
--- a/tests/tools_test.c
+++ b/tests/tools_test.c
@@ -28,7 +28,11 @@
#include <fcntl.h>
#include <libgen.h>
#include <unistd.h>
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <limits.h>
+#endif
#define TOOLS "../tools/"
diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c
index ad5ee6a6..3e53c6d9 100644
--- a/tools/intel_gvtg_test.c
+++ b/tools/intel_gvtg_test.c
@@ -55,6 +55,10 @@
#include <limits.h>
#include <dirent.h>
+#ifdef __FreeBSD__
+#include <sys/wait.h>
+#endif
+
#define RANDOM(x) (rand() % x)
--
2.37.0 (Apple Git-136)
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility
2022-09-28 20:21 Jake Freeland
@ 2022-10-04 9:41 ` Petri Latvala
2022-10-06 2:30 ` Jake Freeland
0 siblings, 1 reply; 20+ messages in thread
From: Petri Latvala @ 2022-10-04 9:41 UTC (permalink / raw)
To: Jake Freeland; +Cc: igt-dev, Jake Freeland
On Wed, Sep 28, 2022 at 03:21:52PM -0500, Jake Freeland wrote:
> FreeBSD's Linux compatbility layer, LinuxKPI, has introduced
> modern drm drivers to the FreeBSD desktop. With drm drivers,
> comes the need for drm testing. This patch allows a portion
> of igt-gpu-tools to compile on FreeBSD
>
> Signed-off-by: Jake Freeland <jfree@freebsd.org>
> ---
> benchmarks/gem_exec_tracer.c | 4 ++
> benchmarks/gem_syslatency.c | 6 ++
> include/linux-uapi/sync_file.h | 5 ++
> lib/i915/intel_memory_region.c | 4 ++
> lib/i915/perf.c | 2 +
> lib/igt_audio.c | 4 ++
> lib/igt_aux.c | 2 +
> lib/igt_aux.h | 6 +-
> lib/igt_core.c | 8 ++-
> lib/igt_core.h | 7 ++
> lib/igt_debugfs.c | 2 +
> lib/igt_device.c | 2 +
> lib/igt_device_scan.c | 4 ++
> lib/igt_eld.c | 4 ++
> lib/igt_frame.c | 4 ++
> lib/igt_freebsd.h | 121 +++++++++++++++++++++++++++++++++
> lib/igt_kmod.h | 2 +
> lib/igt_kms.c | 4 ++
> lib/igt_os.c | 19 ++++++
> lib/igt_perf.c | 2 +
> lib/igt_perf.h | 4 ++
> lib/igt_pm.c | 2 +
> lib/igt_sysfs.c | 2 +
> lib/tests/igt_exit_handler.c | 4 ++
> lib/tests/igt_fork.c | 2 +-
> lib/tests/igt_tests_common.h | 9 +++
> runner/executor.c | 6 ++
> runner/job_list.c | 5 ++
> tests/i915/gem_close_race.c | 2 +
> tests/i915/gem_mmap_gtt.c | 2 +-
> tests/i915/gem_mmap_offset.c | 2 +-
> tests/i915/i915_module_load.c | 2 +
> tests/i915/i915_pm_backlight.c | 4 ++
> tests/i915/i915_pm_rpm.c | 8 +++
> tests/kms_content_protection.c | 2 +
> tests/kms_flip.c | 4 ++
> tests/kms_sysfs_edid_timing.c | 4 ++
> tests/tools_test.c | 4 ++
> tools/intel_gvtg_test.c | 4 ++
> 39 files changed, 274 insertions(+), 10 deletions(-)
> create mode 100644 lib/igt_freebsd.h
>
> diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
> index e6973991..7e86473e 100644
> --- a/benchmarks/gem_exec_tracer.c
> +++ b/benchmarks/gem_exec_tracer.c
> @@ -41,6 +41,10 @@
> #include "intel_aub.h"
> #include "intel_chipset.h"
>
> +#ifdef __FreeBSD__
> +#include "igt_freebsd.h"
> +#endif
> +
> static int (*libc_close)(int fd);
> static int (*libc_ioctl)(int fd, unsigned long request, void *argp);
>
> diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
> index 035ee934..dafc6ac0 100644
> --- a/benchmarks/gem_syslatency.c
> +++ b/benchmarks/gem_syslatency.c
> @@ -42,12 +42,18 @@
> #include <limits.h>
> #include "drm.h"
>
> +#ifdef __linux__
> #include <linux/unistd.h>
> +#elif defined(__FreeBSD__)
> +#include "igt_freebsd.h"
> +#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/include/linux-uapi/sync_file.h b/include/linux-uapi/sync_file.h
> index b4f2db00..270c1cbc 100644
> --- a/include/linux-uapi/sync_file.h
> +++ b/include/linux-uapi/sync_file.h
> @@ -12,8 +12,13 @@
> #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 "igt_freebsd.h"
> +#endif
>
> /**
> * struct sync_merge_data - data passed to merge ioctl
> diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
> index 568bace9..0a59f290 100644
> --- a/lib/i915/intel_memory_region.c
> +++ b/lib/i915/intel_memory_region.c
> @@ -21,7 +21,11 @@
> * IN THE SOFTWARE.
> */
>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#elif defined(__FreeBSD__)
> +#include <limits.h>
> +#endif
> #include <signal.h>
> #include <sys/ioctl.h>
> #include <sys/time.h>
> diff --git a/lib/i915/perf.c b/lib/i915/perf.c
> index d88835ff..beda6b8a 100644
> --- a/lib/i915/perf.c
> +++ b/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/lib/igt_audio.c b/lib/igt_audio.c
> index e0b1bafe..201a39c6 100644
> --- a/lib/igt_audio.c
> +++ b/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/lib/igt_aux.c b/lib/igt_aux.c
> index edb53425..d7e2714f 100644
> --- a/lib/igt_aux.c
> +++ b/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"
> diff --git a/lib/igt_aux.h b/lib/igt_aux.h
> index c8d487b6..912f36c1 100644
> --- a/lib/igt_aux.h
> +++ b/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/lib/igt_core.c b/lib/igt_core.c
> index e7425326..17d5e013 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -43,9 +43,7 @@
> #include <unistd.h>
> #include <sys/wait.h>
> #include <sys/types.h>
> -#ifdef __linux__
> #include <sys/syscall.h>
> -#endif
> #include <pthread.h>
> #include <sys/utsname.h>
> #include <termios.h>
> @@ -786,6 +784,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
>
> static void oom_adjust_for_doom(void)
> {
> +#ifdef __linux__
> int fd;
> const char always_kill[] = "1000";
>
> @@ -793,7 +792,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
> }
>
> /**
> @@ -2224,6 +2223,9 @@ bool __igt_fork_helper(struct igt_helper_process *proc)
> case 0:
> reset_helper_process_list();
> oom_adjust_for_doom();
> +#ifdef __FreeBSD__
> + raise(SIGTERM);
> +#endif
Can't say I understand why this is added. Is this a /* TODO */ of some
description?
--
Petri Latvala
>
> return true;
> default:
> diff --git a/lib/igt_core.h b/lib/igt_core.h
> index aa98e8ed..18e1009d 100644
> --- a/lib/igt_core.h
> +++ b/lib/igt_core.h
> @@ -31,7 +31,11 @@
> #define IGT_CORE_H
>
> #include <assert.h>
> +#ifdef __linux__
> #include <byteswap.h>
> +#elif defined(__FreeBSD__)
> +#include <sys/endian.h>
> +#endif
> #include <setjmp.h>
> #include <stdbool.h>
> #include <stdint.h>
> @@ -47,6 +51,9 @@
> #define IGT_LOG_DOMAIN (NULL)
> #endif
>
> +#ifdef __FreeBSD__
> +#include "igt_freebsd.h"
> +#endif
>
> #ifndef STATIC_ANALYSIS_BUILD
> #if defined(__clang_analyzer__) || defined(__COVERITY__) || defined(__KLOCWORK__)
> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> index a56688a5..fa1e3b69 100644
> --- a/lib/igt_debugfs.c
> +++ b/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>
> diff --git a/lib/igt_device.c b/lib/igt_device.c
> index fddfba72..49b77122 100644
> --- a/lib/igt_device.c
> +++ b/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/lib/igt_device_scan.c b/lib/igt_device_scan.c
> index eb6b45b8..6a921d52 100644
> --- a/lib/igt_device_scan.c
> +++ b/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/lib/igt_eld.c b/lib/igt_eld.c
> index ef6625df..e05ad6de 100644
> --- a/lib/igt_eld.c
> +++ b/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/lib/igt_frame.c b/lib/igt_frame.c
> index 45523a79..ab74e678 100644
> --- a/lib/igt_frame.c
> +++ b/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/lib/igt_freebsd.h b/lib/igt_freebsd.h
> new file mode 100644
> index 00000000..81ba5c01
> --- /dev/null
> +++ b/lib/igt_freebsd.h
> @@ -0,0 +1,121 @@
> +/*
> + * SPDX-License-Identifier: MIT
> + *
> + * Copyright (c) 2022, Jake Freeland <jfree@FreeBSD.org>
> + *
> + * 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.
> + */
> +
> +#if !defined(IGT_FREEBSD_H) && defined(__FreeBSD__)
> +#define IGT_FREEBSD_H
> +
> +#include <sys/errno.h>
> +#include <sys/mman.h>
> +#include <sys/mount.h>
> +#include <sys/sched.h>
> +#include <sys/types.h>
> +#include <sys/watchdog.h>
> +
> +#include <pthread.h>
> +#include <setjmp.h>
> +#include <signal.h>
> +#include <unistd.h>
> +
> +/*
> + * Proper substitutions:
> + * The following macros replace Linux-specific functions
> + * and macros with their FreeBSD equivalents.
> + */
> +
> +#define __s32 int32_t
> +#define __u32 uint32_t
> +#define __u64 uint64_t
> +
> +#define sighandler_t sig_t
> +#define ino64_t ino_t
> +
> +#define jmp_buf sigjmp_buf
> +
> +#define PTRACE_TRACEME PT_TRACE_ME
> +#define PTRACE_ATTACH PT_ATTACH
> +#define PTRACE_PEEKDATA PT_READ_D
> +#define PTRACE_POKEDATA PT_WRITE_D
> +#define PTRACE_DETACH PT_DETACH
> +
> +#define I2C_RDWR I2CRDWR
> +#define I2C_M_RD IIC_M_RD
> +#define i2c_msg iic_msg
> +#define i2c_rdwr_ioctl_data iic_rdwr_data
> +
> +#define _IOC_TYPE(nr) (((nr) >> 8) & 255)
> +
> +#define SYS_getdents64 SYS_freebsd11_getdents
> +
> +#define mount(src, dest, fstype, flags, data) \
> + mount(fstype, dest, flags, data)
> +
> +/*
> + * Improper substitutions:
> + * The following macros are temporary replacements for functions
> + * and macros that exist on Linux and do not exist on FreeBSD.
> + */
> +
> +#define ETIME ETIMEDOUT
> +
> +#define MAP_POPULATE MAP_PREFAULT_READ
> +
> +#define MADV_HUGEPAGE MADV_SEQUENTIAL
> +#define MADV_DONTFORK MADV_NOSYNC
> +
> +#define WDIOC_KEEPALIVE WDIOCPATPAT
> +
> +#define SCHED_RESET_ON_FORK 0
> +#define SCHED_IDLE SCHED_OTHER
> +
> +#define gettid() getpid()
> +
> +#define pthread_sigqueue(pid, signo, value) \
> + sigqueue(pid, signo, value)
> +
> +#define signalfd(fd, mask, flags) -ENOSYS
> +#define timerfd_create(c, f) -ENOSYS
> +#define timerfd_settime(fd, f, n, o) -ENOSYS
> +
> +/*
> + * Macro conflict resolution.
> + */
> +
> +#undef ALIGN
> +#undef PAGE_SIZE
> +
> +struct signalfd_siginfo {
> + uint32_t ssi_signo;
> + uint32_t ssi_pid;
> +};
> +
> +struct kmod_module {
> + size_t size;
> +};
> +
> +typedef struct {
> + char state;
> +} proc_t;
> +
> +#endif /* IGT_FREEBSD_H */
> diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
> index f98dd29f..6596092b 100644
> --- a/lib/igt_kmod.h
> +++ b/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/lib/igt_kms.c b/lib/igt_kms.c
> index 665594aa..532a3aa8 100644
> --- a/lib/igt_kms.c
> +++ b/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/lib/igt_os.c b/lib/igt_os.c
> index bdd5d933..bb6994e1 100644
> --- a/lib/igt_os.c
> +++ b/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__)
> + 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__)
> + 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/lib/igt_perf.c b/lib/igt_perf.c
> index b743859f..11c91c5f 100644
> --- a/lib/igt_perf.c
> +++ b/lib/igt_perf.c
> @@ -4,8 +4,10 @@
> #include <stdlib.h>
> #include <string.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <sys/sysinfo.h>
> #include <sys/sysmacros.h>
> +#endif
> #include <time.h>
> #include <unistd.h>
>
> diff --git a/lib/igt_perf.h b/lib/igt_perf.h
> index a8328c70..0cd91386 100644
> --- a/lib/igt_perf.h
> +++ b/lib/igt_perf.h
> @@ -27,10 +27,13 @@
>
> #include <stdint.h>
>
> +#ifdef __linux__
> #include <linux/perf_event.h>
> +#endif
>
> #include "igt_gt.h"
>
> +#ifdef __linux__
> static inline int
> perf_event_open(struct perf_event_attr *attr,
> pid_t pid,
> @@ -50,6 +53,7 @@ perf_event_open(struct perf_event_attr *attr,
> attr->size = sizeof(*attr);
> return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);
> }
> +#endif /* __linux__ */
>
> uint64_t igt_perf_type_id(const char *device);
> int igt_perf_open(uint64_t type, uint64_t config);
> diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> index 312288d0..1e6e9ed3 100644
> --- a/lib/igt_pm.c
> +++ b/lib/igt_pm.c
> @@ -33,7 +33,9 @@
> #include <string.h>
> #include <unistd.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <sys/sysmacros.h>
> +#endif
> #include <sys/types.h>
> #include <dirent.h>
>
> diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
> index 9c307694..a913be4c 100644
> --- a/lib/igt_sysfs.c
> +++ b/lib/igt_sysfs.c
> @@ -24,7 +24,9 @@
>
> #include <inttypes.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <sys/sysmacros.h>
> +#endif
> #include <sys/mount.h>
> #include <errno.h>
> #include <stdarg.h>
> diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
> index 892a7f14..d2381944 100644
> --- a/lib/tests/igt_exit_handler.c
> +++ b/lib/tests/igt_exit_handler.c
> @@ -125,5 +125,9 @@ int main(int argc, char **argv)
> internal_assert_wexited(status, IGT_EXIT_SKIP);
>
> status = testfunc(SIG);
> +#ifdef __linux__
> internal_assert_wsignaled(status, SIGTERM);
> +#elif defined(__FreeBSD__)
> + internal_assert(status == 0);
> +#endif
> }
> diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
> index d19d0945..c7193b06 100644
> --- a/lib/tests/igt_fork.c
> +++ b/lib/tests/igt_fork.c
> @@ -109,7 +109,7 @@ __noreturn static void igt_fork_timeout_leak(void)
> __noreturn static void subtest_leak(void)
> {
> pid_t *children =
> - mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
> + mmap(0, 4096, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANON, -1, 0);
> const int num_children = 4096 / sizeof(*children);
>
> igt_subtest_init(fake_argc, fake_argv);
> diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
> index 058f6265..e8183897 100644
> --- a/lib/tests/igt_tests_common.h
> +++ b/lib/tests/igt_tests_common.h
> @@ -48,8 +48,17 @@ static inline void internal_assert_wexited(int wstatus, int exitcode)
>
> static inline void internal_assert_wsignaled(int wstatus, int signal)
> {
> +#ifdef __linux__
> internal_assert(WIFSIGNALED(wstatus) &&
> WTERMSIG(wstatus) == signal);
> +#elif defined(__FreeBSD__)
> + if (WIFSIGNALED(wstatus))
> + internal_assert(WTERMSIG(wstatus) == signal);
> + else if (WIFEXITED(wstatus))
> + internal_assert(WEXITSTATUS(wstatus) == signal + 128);
> + else
> + internal_assert(0);
> +#endif
> }
>
> static inline void internal_assert_not_wsignaled(int wstatus)
> diff --git a/runner/executor.c b/runner/executor.c
> index 964d0063..c54072cf 100644
> --- a/runner/executor.c
> +++ b/runner/executor.c
> @@ -2,7 +2,9 @@
> #include <errno.h>
> #include <fcntl.h>
> #include <glib.h>
> +#ifdef __linux__
> #include <linux/watchdog.h>
> +#endif
> #if HAVE_OPING
> #include <oping.h>
> #endif
> @@ -33,6 +35,10 @@
> #define KMSG_HEADER "[IGT] "
> #define KMSG_WARN 4
>
> +#ifdef __FreeBSD__
> +#include <sys/watchdog.h>
> +#endif
> +
> static struct {
> int *fds;
> size_t num_dogs;
> diff --git a/runner/job_list.c b/runner/job_list.c
> index 520a98da..6bfa7162 100644
> --- a/runner/job_list.c
> +++ b/runner/job_list.c
> @@ -1,7 +1,12 @@
> #include <ctype.h>
> #include <errno.h>
> #include <fcntl.h>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#elif defined(__FreeBSD__)
> +#include <sys/wait.h>
> +#include <limits.h>
> +#endif
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
> index 938fde8f..42fe1657 100644
> --- a/tests/i915/gem_close_race.c
> +++ b/tests/i915/gem_close_race.c
> @@ -61,7 +61,9 @@ static bool has_softpin;
> static uint64_t exec_addr;
> static uint64_t data_addr;
>
> +#ifdef __linux__
> #define sigev_notify_thread_id _sigev_un._tid
> +#endif
>
> static void selfcopy(int fd, uint32_t ctx, uint32_t handle, int loops)
> {
> diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
> index e39b9047..4f05eb18 100644
> --- a/tests/i915/gem_mmap_gtt.c
> +++ b/tests/i915/gem_mmap_gtt.c
> @@ -566,7 +566,7 @@ test_ptrace(int fd)
> for (int i = 0; i < sz / sizeof(long); i++) {
> long ret;
>
> - ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i);
> + ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i, NULL);
> igt_assert_eq_u64(ret, CC);
> cpy[i] = ret;
>
> diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
> index 7e8c02d1..fc4245f6 100644
> --- a/tests/i915/gem_mmap_offset.c
> +++ b/tests/i915/gem_mmap_offset.c
> @@ -520,7 +520,7 @@ static void test_ptrace(int i915)
> for (int i = 0; i < SZ / sizeof(long); i++) {
> long ret;
>
> - ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i);
> + ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i, NULL);
> igt_assert_eq_u64(ret, CC);
> cpy[i] = ret;
>
> diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c
> index 4c72157c..9bec4c18 100644
> --- a/tests/i915/i915_module_load.c
> +++ b/tests/i915/i915_module_load.c
> @@ -23,7 +23,9 @@
> #include "igt.h"
> #include <dirent.h>
> #include <sys/utsname.h>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#endif
> #include <signal.h>
> #include <libgen.h>
> #include <signal.h>
> diff --git a/tests/i915/i915_pm_backlight.c b/tests/i915/i915_pm_backlight.c
> index cafae7f7..c520cf20 100644
> --- a/tests/i915/i915_pm_backlight.c
> +++ b/tests/i915/i915_pm_backlight.c
> @@ -46,6 +46,10 @@ struct context {
> #define FADESTEPS 10
> #define FADESPEED 100 /* milliseconds between steps */
>
> +#ifdef __FreeBSD__
> +#include <libgen.h>
> +#endif
> +
> IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
>
> static int backlight_read(int *result, const char *fname)
> diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
> index e95875dc..761e76f9 100644
> --- a/tests/i915/i915_pm_rpm.c
> +++ b/tests/i915/i915_pm_rpm.c
> @@ -40,8 +40,10 @@
> #include <sys/mman.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <linux/i2c.h>
> #include <linux/i2c-dev.h>
> +#endif
>
> #include <drm.h>
>
> @@ -54,6 +56,12 @@
> #include "igt_device.h"
> #include "igt_edid.h"
>
> +#ifdef __FreeBSD__
> +#include <limits.h>
> +#include <dev/iicbus/iic.h>
> +#define addr slave
> +#endif
> +
> #define MSR_PC8_RES 0x630
> #define MSR_PC9_RES 0x631
> #define MSR_PC10_RES 0x632
> diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
> index 3041f1cd..e0e5af78 100644
> --- a/tests/kms_content_protection.c
> +++ b/tests/kms_content_protection.c
> @@ -24,7 +24,9 @@
>
> #include <poll.h>
> #include <fcntl.h>
> +#ifdef __linux__
> #include <sys/epoll.h>
> +#endif
> #include <sys/stat.h>
> #include <libudev.h>
> #include "igt.h"
> diff --git a/tests/kms_flip.c b/tests/kms_flip.c
> index 0567edea..1127e418 100755
> --- a/tests/kms_flip.c
> +++ b/tests/kms_flip.c
> @@ -45,6 +45,10 @@
> #include "i915/gem_create.h"
> #include "igt_stats.h"
>
> +#ifdef __FreeBSD__
> +#include <sys/consio.h>
> +#endif
> +
> #define TEST_DPMS (1 << 0)
>
> #define TEST_PAN (1 << 3)
> diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
> index 77521108..cd980c6a 100644
> --- a/tests/kms_sysfs_edid_timing.c
> +++ b/tests/kms_sysfs_edid_timing.c
> @@ -26,6 +26,10 @@
> #include <fcntl.h>
> #include <sys/stat.h>
>
> +#ifdef __FreeBSD__
> +#include <limits.h>
> +#endif
> +
> #define THRESHOLD_PER_CONNECTOR 150
> #define THRESHOLD_PER_CONNECTOR_MEAN 140
> #define THRESHOLD_ALL_CONNECTORS_MEAN 100
> diff --git a/tests/tools_test.c b/tests/tools_test.c
> index 237f0433..89a19d11 100644
> --- a/tests/tools_test.c
> +++ b/tests/tools_test.c
> @@ -28,7 +28,11 @@
> #include <fcntl.h>
> #include <libgen.h>
> #include <unistd.h>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#elif defined(__FreeBSD__)
> +#include <limits.h>
> +#endif
>
> #define TOOLS "../tools/"
>
> diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c
> index ad5ee6a6..3e53c6d9 100644
> --- a/tools/intel_gvtg_test.c
> +++ b/tools/intel_gvtg_test.c
> @@ -55,6 +55,10 @@
> #include <limits.h>
> #include <dirent.h>
>
> +#ifdef __FreeBSD__
> +#include <sys/wait.h>
> +#endif
> +
> #define RANDOM(x) (rand() % x)
>
>
> --
> 2.37.3
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility
@ 2022-09-28 20:21 Jake Freeland
2022-10-04 9:41 ` Petri Latvala
0 siblings, 1 reply; 20+ messages in thread
From: Jake Freeland @ 2022-09-28 20:21 UTC (permalink / raw)
To: igt-dev; +Cc: Jake Freeland
FreeBSD's Linux compatbility layer, LinuxKPI, has introduced
modern drm drivers to the FreeBSD desktop. With drm drivers,
comes the need for drm testing. This patch allows a portion
of igt-gpu-tools to compile on FreeBSD
Signed-off-by: Jake Freeland <jfree@freebsd.org>
---
benchmarks/gem_exec_tracer.c | 4 ++
benchmarks/gem_syslatency.c | 6 ++
include/linux-uapi/sync_file.h | 5 ++
lib/i915/intel_memory_region.c | 4 ++
lib/i915/perf.c | 2 +
lib/igt_audio.c | 4 ++
lib/igt_aux.c | 2 +
lib/igt_aux.h | 6 +-
lib/igt_core.c | 8 ++-
lib/igt_core.h | 7 ++
lib/igt_debugfs.c | 2 +
lib/igt_device.c | 2 +
lib/igt_device_scan.c | 4 ++
lib/igt_eld.c | 4 ++
lib/igt_frame.c | 4 ++
lib/igt_freebsd.h | 121 +++++++++++++++++++++++++++++++++
lib/igt_kmod.h | 2 +
lib/igt_kms.c | 4 ++
lib/igt_os.c | 19 ++++++
lib/igt_perf.c | 2 +
lib/igt_perf.h | 4 ++
lib/igt_pm.c | 2 +
lib/igt_sysfs.c | 2 +
lib/tests/igt_exit_handler.c | 4 ++
lib/tests/igt_fork.c | 2 +-
lib/tests/igt_tests_common.h | 9 +++
runner/executor.c | 6 ++
runner/job_list.c | 5 ++
tests/i915/gem_close_race.c | 2 +
tests/i915/gem_mmap_gtt.c | 2 +-
tests/i915/gem_mmap_offset.c | 2 +-
tests/i915/i915_module_load.c | 2 +
tests/i915/i915_pm_backlight.c | 4 ++
tests/i915/i915_pm_rpm.c | 8 +++
tests/kms_content_protection.c | 2 +
tests/kms_flip.c | 4 ++
tests/kms_sysfs_edid_timing.c | 4 ++
tests/tools_test.c | 4 ++
tools/intel_gvtg_test.c | 4 ++
39 files changed, 274 insertions(+), 10 deletions(-)
create mode 100644 lib/igt_freebsd.h
diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
index e6973991..7e86473e 100644
--- a/benchmarks/gem_exec_tracer.c
+++ b/benchmarks/gem_exec_tracer.c
@@ -41,6 +41,10 @@
#include "intel_aub.h"
#include "intel_chipset.h"
+#ifdef __FreeBSD__
+#include "igt_freebsd.h"
+#endif
+
static int (*libc_close)(int fd);
static int (*libc_ioctl)(int fd, unsigned long request, void *argp);
diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
index 035ee934..dafc6ac0 100644
--- a/benchmarks/gem_syslatency.c
+++ b/benchmarks/gem_syslatency.c
@@ -42,12 +42,18 @@
#include <limits.h>
#include "drm.h"
+#ifdef __linux__
#include <linux/unistd.h>
+#elif defined(__FreeBSD__)
+#include "igt_freebsd.h"
+#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/include/linux-uapi/sync_file.h b/include/linux-uapi/sync_file.h
index b4f2db00..270c1cbc 100644
--- a/include/linux-uapi/sync_file.h
+++ b/include/linux-uapi/sync_file.h
@@ -12,8 +12,13 @@
#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 "igt_freebsd.h"
+#endif
/**
* struct sync_merge_data - data passed to merge ioctl
diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
index 568bace9..0a59f290 100644
--- a/lib/i915/intel_memory_region.c
+++ b/lib/i915/intel_memory_region.c
@@ -21,7 +21,11 @@
* IN THE SOFTWARE.
*/
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <limits.h>
+#endif
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/time.h>
diff --git a/lib/i915/perf.c b/lib/i915/perf.c
index d88835ff..beda6b8a 100644
--- a/lib/i915/perf.c
+++ b/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/lib/igt_audio.c b/lib/igt_audio.c
index e0b1bafe..201a39c6 100644
--- a/lib/igt_audio.c
+++ b/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/lib/igt_aux.c b/lib/igt_aux.c
index edb53425..d7e2714f 100644
--- a/lib/igt_aux.c
+++ b/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"
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index c8d487b6..912f36c1 100644
--- a/lib/igt_aux.h
+++ b/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/lib/igt_core.c b/lib/igt_core.c
index e7425326..17d5e013 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -43,9 +43,7 @@
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
-#ifdef __linux__
#include <sys/syscall.h>
-#endif
#include <pthread.h>
#include <sys/utsname.h>
#include <termios.h>
@@ -786,6 +784,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
static void oom_adjust_for_doom(void)
{
+#ifdef __linux__
int fd;
const char always_kill[] = "1000";
@@ -793,7 +792,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
}
/**
@@ -2224,6 +2223,9 @@ bool __igt_fork_helper(struct igt_helper_process *proc)
case 0:
reset_helper_process_list();
oom_adjust_for_doom();
+#ifdef __FreeBSD__
+ raise(SIGTERM);
+#endif
return true;
default:
diff --git a/lib/igt_core.h b/lib/igt_core.h
index aa98e8ed..18e1009d 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -31,7 +31,11 @@
#define IGT_CORE_H
#include <assert.h>
+#ifdef __linux__
#include <byteswap.h>
+#elif defined(__FreeBSD__)
+#include <sys/endian.h>
+#endif
#include <setjmp.h>
#include <stdbool.h>
#include <stdint.h>
@@ -47,6 +51,9 @@
#define IGT_LOG_DOMAIN (NULL)
#endif
+#ifdef __FreeBSD__
+#include "igt_freebsd.h"
+#endif
#ifndef STATIC_ANALYSIS_BUILD
#if defined(__clang_analyzer__) || defined(__COVERITY__) || defined(__KLOCWORK__)
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index a56688a5..fa1e3b69 100644
--- a/lib/igt_debugfs.c
+++ b/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>
diff --git a/lib/igt_device.c b/lib/igt_device.c
index fddfba72..49b77122 100644
--- a/lib/igt_device.c
+++ b/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/lib/igt_device_scan.c b/lib/igt_device_scan.c
index eb6b45b8..6a921d52 100644
--- a/lib/igt_device_scan.c
+++ b/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/lib/igt_eld.c b/lib/igt_eld.c
index ef6625df..e05ad6de 100644
--- a/lib/igt_eld.c
+++ b/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/lib/igt_frame.c b/lib/igt_frame.c
index 45523a79..ab74e678 100644
--- a/lib/igt_frame.c
+++ b/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/lib/igt_freebsd.h b/lib/igt_freebsd.h
new file mode 100644
index 00000000..81ba5c01
--- /dev/null
+++ b/lib/igt_freebsd.h
@@ -0,0 +1,121 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (c) 2022, Jake Freeland <jfree@FreeBSD.org>
+ *
+ * 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.
+ */
+
+#if !defined(IGT_FREEBSD_H) && defined(__FreeBSD__)
+#define IGT_FREEBSD_H
+
+#include <sys/errno.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/sched.h>
+#include <sys/types.h>
+#include <sys/watchdog.h>
+
+#include <pthread.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <unistd.h>
+
+/*
+ * Proper substitutions:
+ * The following macros replace Linux-specific functions
+ * and macros with their FreeBSD equivalents.
+ */
+
+#define __s32 int32_t
+#define __u32 uint32_t
+#define __u64 uint64_t
+
+#define sighandler_t sig_t
+#define ino64_t ino_t
+
+#define jmp_buf sigjmp_buf
+
+#define PTRACE_TRACEME PT_TRACE_ME
+#define PTRACE_ATTACH PT_ATTACH
+#define PTRACE_PEEKDATA PT_READ_D
+#define PTRACE_POKEDATA PT_WRITE_D
+#define PTRACE_DETACH PT_DETACH
+
+#define I2C_RDWR I2CRDWR
+#define I2C_M_RD IIC_M_RD
+#define i2c_msg iic_msg
+#define i2c_rdwr_ioctl_data iic_rdwr_data
+
+#define _IOC_TYPE(nr) (((nr) >> 8) & 255)
+
+#define SYS_getdents64 SYS_freebsd11_getdents
+
+#define mount(src, dest, fstype, flags, data) \
+ mount(fstype, dest, flags, data)
+
+/*
+ * Improper substitutions:
+ * The following macros are temporary replacements for functions
+ * and macros that exist on Linux and do not exist on FreeBSD.
+ */
+
+#define ETIME ETIMEDOUT
+
+#define MAP_POPULATE MAP_PREFAULT_READ
+
+#define MADV_HUGEPAGE MADV_SEQUENTIAL
+#define MADV_DONTFORK MADV_NOSYNC
+
+#define WDIOC_KEEPALIVE WDIOCPATPAT
+
+#define SCHED_RESET_ON_FORK 0
+#define SCHED_IDLE SCHED_OTHER
+
+#define gettid() getpid()
+
+#define pthread_sigqueue(pid, signo, value) \
+ sigqueue(pid, signo, value)
+
+#define signalfd(fd, mask, flags) -ENOSYS
+#define timerfd_create(c, f) -ENOSYS
+#define timerfd_settime(fd, f, n, o) -ENOSYS
+
+/*
+ * Macro conflict resolution.
+ */
+
+#undef ALIGN
+#undef PAGE_SIZE
+
+struct signalfd_siginfo {
+ uint32_t ssi_signo;
+ uint32_t ssi_pid;
+};
+
+struct kmod_module {
+ size_t size;
+};
+
+typedef struct {
+ char state;
+} proc_t;
+
+#endif /* IGT_FREEBSD_H */
diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
index f98dd29f..6596092b 100644
--- a/lib/igt_kmod.h
+++ b/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/lib/igt_kms.c b/lib/igt_kms.c
index 665594aa..532a3aa8 100644
--- a/lib/igt_kms.c
+++ b/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/lib/igt_os.c b/lib/igt_os.c
index bdd5d933..bb6994e1 100644
--- a/lib/igt_os.c
+++ b/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__)
+ 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__)
+ 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/lib/igt_perf.c b/lib/igt_perf.c
index b743859f..11c91c5f 100644
--- a/lib/igt_perf.c
+++ b/lib/igt_perf.c
@@ -4,8 +4,10 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysinfo.h>
#include <sys/sysmacros.h>
+#endif
#include <time.h>
#include <unistd.h>
diff --git a/lib/igt_perf.h b/lib/igt_perf.h
index a8328c70..0cd91386 100644
--- a/lib/igt_perf.h
+++ b/lib/igt_perf.h
@@ -27,10 +27,13 @@
#include <stdint.h>
+#ifdef __linux__
#include <linux/perf_event.h>
+#endif
#include "igt_gt.h"
+#ifdef __linux__
static inline int
perf_event_open(struct perf_event_attr *attr,
pid_t pid,
@@ -50,6 +53,7 @@ perf_event_open(struct perf_event_attr *attr,
attr->size = sizeof(*attr);
return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);
}
+#endif /* __linux__ */
uint64_t igt_perf_type_id(const char *device);
int igt_perf_open(uint64_t type, uint64_t config);
diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 312288d0..1e6e9ed3 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,7 +33,9 @@
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysmacros.h>
+#endif
#include <sys/types.h>
#include <dirent.h>
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 9c307694..a913be4c 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -24,7 +24,9 @@
#include <inttypes.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysmacros.h>
+#endif
#include <sys/mount.h>
#include <errno.h>
#include <stdarg.h>
diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
index 892a7f14..d2381944 100644
--- a/lib/tests/igt_exit_handler.c
+++ b/lib/tests/igt_exit_handler.c
@@ -125,5 +125,9 @@ int main(int argc, char **argv)
internal_assert_wexited(status, IGT_EXIT_SKIP);
status = testfunc(SIG);
+#ifdef __linux__
internal_assert_wsignaled(status, SIGTERM);
+#elif defined(__FreeBSD__)
+ internal_assert(status == 0);
+#endif
}
diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
index d19d0945..c7193b06 100644
--- a/lib/tests/igt_fork.c
+++ b/lib/tests/igt_fork.c
@@ -109,7 +109,7 @@ __noreturn static void igt_fork_timeout_leak(void)
__noreturn static void subtest_leak(void)
{
pid_t *children =
- mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+ mmap(0, 4096, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANON, -1, 0);
const int num_children = 4096 / sizeof(*children);
igt_subtest_init(fake_argc, fake_argv);
diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
index 058f6265..e8183897 100644
--- a/lib/tests/igt_tests_common.h
+++ b/lib/tests/igt_tests_common.h
@@ -48,8 +48,17 @@ static inline void internal_assert_wexited(int wstatus, int exitcode)
static inline void internal_assert_wsignaled(int wstatus, int signal)
{
+#ifdef __linux__
internal_assert(WIFSIGNALED(wstatus) &&
WTERMSIG(wstatus) == signal);
+#elif defined(__FreeBSD__)
+ if (WIFSIGNALED(wstatus))
+ internal_assert(WTERMSIG(wstatus) == signal);
+ else if (WIFEXITED(wstatus))
+ internal_assert(WEXITSTATUS(wstatus) == signal + 128);
+ else
+ internal_assert(0);
+#endif
}
static inline void internal_assert_not_wsignaled(int wstatus)
diff --git a/runner/executor.c b/runner/executor.c
index 964d0063..c54072cf 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -2,7 +2,9 @@
#include <errno.h>
#include <fcntl.h>
#include <glib.h>
+#ifdef __linux__
#include <linux/watchdog.h>
+#endif
#if HAVE_OPING
#include <oping.h>
#endif
@@ -33,6 +35,10 @@
#define KMSG_HEADER "[IGT] "
#define KMSG_WARN 4
+#ifdef __FreeBSD__
+#include <sys/watchdog.h>
+#endif
+
static struct {
int *fds;
size_t num_dogs;
diff --git a/runner/job_list.c b/runner/job_list.c
index 520a98da..6bfa7162 100644
--- a/runner/job_list.c
+++ b/runner/job_list.c
@@ -1,7 +1,12 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <sys/wait.h>
+#include <limits.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
index 938fde8f..42fe1657 100644
--- a/tests/i915/gem_close_race.c
+++ b/tests/i915/gem_close_race.c
@@ -61,7 +61,9 @@ static bool has_softpin;
static uint64_t exec_addr;
static uint64_t data_addr;
+#ifdef __linux__
#define sigev_notify_thread_id _sigev_un._tid
+#endif
static void selfcopy(int fd, uint32_t ctx, uint32_t handle, int loops)
{
diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
index e39b9047..4f05eb18 100644
--- a/tests/i915/gem_mmap_gtt.c
+++ b/tests/i915/gem_mmap_gtt.c
@@ -566,7 +566,7 @@ test_ptrace(int fd)
for (int i = 0; i < sz / sizeof(long); i++) {
long ret;
- ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i);
+ ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i, NULL);
igt_assert_eq_u64(ret, CC);
cpy[i] = ret;
diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
index 7e8c02d1..fc4245f6 100644
--- a/tests/i915/gem_mmap_offset.c
+++ b/tests/i915/gem_mmap_offset.c
@@ -520,7 +520,7 @@ static void test_ptrace(int i915)
for (int i = 0; i < SZ / sizeof(long); i++) {
long ret;
- ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i);
+ ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i, NULL);
igt_assert_eq_u64(ret, CC);
cpy[i] = ret;
diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c
index 4c72157c..9bec4c18 100644
--- a/tests/i915/i915_module_load.c
+++ b/tests/i915/i915_module_load.c
@@ -23,7 +23,9 @@
#include "igt.h"
#include <dirent.h>
#include <sys/utsname.h>
+#ifdef __linux__
#include <linux/limits.h>
+#endif
#include <signal.h>
#include <libgen.h>
#include <signal.h>
diff --git a/tests/i915/i915_pm_backlight.c b/tests/i915/i915_pm_backlight.c
index cafae7f7..c520cf20 100644
--- a/tests/i915/i915_pm_backlight.c
+++ b/tests/i915/i915_pm_backlight.c
@@ -46,6 +46,10 @@ struct context {
#define FADESTEPS 10
#define FADESPEED 100 /* milliseconds between steps */
+#ifdef __FreeBSD__
+#include <libgen.h>
+#endif
+
IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
static int backlight_read(int *result, const char *fname)
diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
index e95875dc..761e76f9 100644
--- a/tests/i915/i915_pm_rpm.c
+++ b/tests/i915/i915_pm_rpm.c
@@ -40,8 +40,10 @@
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
+#endif
#include <drm.h>
@@ -54,6 +56,12 @@
#include "igt_device.h"
#include "igt_edid.h"
+#ifdef __FreeBSD__
+#include <limits.h>
+#include <dev/iicbus/iic.h>
+#define addr slave
+#endif
+
#define MSR_PC8_RES 0x630
#define MSR_PC9_RES 0x631
#define MSR_PC10_RES 0x632
diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
index 3041f1cd..e0e5af78 100644
--- a/tests/kms_content_protection.c
+++ b/tests/kms_content_protection.c
@@ -24,7 +24,9 @@
#include <poll.h>
#include <fcntl.h>
+#ifdef __linux__
#include <sys/epoll.h>
+#endif
#include <sys/stat.h>
#include <libudev.h>
#include "igt.h"
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 0567edea..1127e418 100755
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -45,6 +45,10 @@
#include "i915/gem_create.h"
#include "igt_stats.h"
+#ifdef __FreeBSD__
+#include <sys/consio.h>
+#endif
+
#define TEST_DPMS (1 << 0)
#define TEST_PAN (1 << 3)
diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
index 77521108..cd980c6a 100644
--- a/tests/kms_sysfs_edid_timing.c
+++ b/tests/kms_sysfs_edid_timing.c
@@ -26,6 +26,10 @@
#include <fcntl.h>
#include <sys/stat.h>
+#ifdef __FreeBSD__
+#include <limits.h>
+#endif
+
#define THRESHOLD_PER_CONNECTOR 150
#define THRESHOLD_PER_CONNECTOR_MEAN 140
#define THRESHOLD_ALL_CONNECTORS_MEAN 100
diff --git a/tests/tools_test.c b/tests/tools_test.c
index 237f0433..89a19d11 100644
--- a/tests/tools_test.c
+++ b/tests/tools_test.c
@@ -28,7 +28,11 @@
#include <fcntl.h>
#include <libgen.h>
#include <unistd.h>
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <limits.h>
+#endif
#define TOOLS "../tools/"
diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c
index ad5ee6a6..3e53c6d9 100644
--- a/tools/intel_gvtg_test.c
+++ b/tools/intel_gvtg_test.c
@@ -55,6 +55,10 @@
#include <limits.h>
#include <dirent.h>
+#ifdef __FreeBSD__
+#include <sys/wait.h>
+#endif
+
#define RANDOM(x) (rand() % x)
--
2.37.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility
@ 2022-09-28 19:34 Jake Freeland
0 siblings, 0 replies; 20+ messages in thread
From: Jake Freeland @ 2022-09-28 19:34 UTC (permalink / raw)
To: igt-dev, kamil.konieczny, petri.latvala; +Cc: Jake Freeland
FreeBSD's Linux compatbility layer, LinuxKPI, has introduced
modern drm drivers to the FreeBSD desktop. With drm drivers,
comes the need for drm testing. This patch allows a portion
of igt-gpu-tools to compile on FreeBSD
Signed-off-by: Jake Freeland <jfree@freebsd.org>
---
benchmarks/gem_exec_tracer.c | 4 ++
benchmarks/gem_syslatency.c | 6 ++
include/linux-uapi/sync_file.h | 5 ++
lib/i915/intel_memory_region.c | 4 ++
lib/i915/perf.c | 2 +
lib/igt_audio.c | 4 ++
lib/igt_aux.c | 2 +
lib/igt_aux.h | 6 +-
lib/igt_core.c | 8 ++-
lib/igt_core.h | 7 ++
lib/igt_debugfs.c | 2 +
lib/igt_device.c | 2 +
lib/igt_device_scan.c | 4 ++
lib/igt_eld.c | 4 ++
lib/igt_frame.c | 4 ++
lib/igt_freebsd.h | 121 +++++++++++++++++++++++++++++++++
lib/igt_kmod.h | 2 +
lib/igt_kms.c | 4 ++
lib/igt_os.c | 19 ++++++
lib/igt_perf.c | 2 +
lib/igt_perf.h | 4 ++
lib/igt_pm.c | 2 +
lib/igt_sysfs.c | 2 +
lib/tests/igt_exit_handler.c | 4 ++
lib/tests/igt_fork.c | 2 +-
lib/tests/igt_tests_common.h | 9 +++
runner/executor.c | 6 ++
runner/job_list.c | 5 ++
tests/i915/gem_close_race.c | 2 +
tests/i915/gem_mmap_gtt.c | 2 +-
tests/i915/gem_mmap_offset.c | 2 +-
tests/i915/i915_module_load.c | 2 +
tests/i915/i915_pm_backlight.c | 4 ++
tests/i915/i915_pm_rpm.c | 8 +++
tests/kms_content_protection.c | 2 +
tests/kms_flip.c | 4 ++
tests/kms_sysfs_edid_timing.c | 4 ++
tests/tools_test.c | 4 ++
tools/intel_gvtg_test.c | 4 ++
39 files changed, 274 insertions(+), 10 deletions(-)
create mode 100644 lib/igt_freebsd.h
diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
index e6973991..7e86473e 100644
--- a/benchmarks/gem_exec_tracer.c
+++ b/benchmarks/gem_exec_tracer.c
@@ -41,6 +41,10 @@
#include "intel_aub.h"
#include "intel_chipset.h"
+#ifdef __FreeBSD__
+#include "igt_freebsd.h"
+#endif
+
static int (*libc_close)(int fd);
static int (*libc_ioctl)(int fd, unsigned long request, void *argp);
diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
index 035ee934..dafc6ac0 100644
--- a/benchmarks/gem_syslatency.c
+++ b/benchmarks/gem_syslatency.c
@@ -42,12 +42,18 @@
#include <limits.h>
#include "drm.h"
+#ifdef __linux__
#include <linux/unistd.h>
+#elif defined(__FreeBSD__)
+#include "igt_freebsd.h"
+#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/include/linux-uapi/sync_file.h b/include/linux-uapi/sync_file.h
index b4f2db00..270c1cbc 100644
--- a/include/linux-uapi/sync_file.h
+++ b/include/linux-uapi/sync_file.h
@@ -12,8 +12,13 @@
#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 "igt_freebsd.h"
+#endif
/**
* struct sync_merge_data - data passed to merge ioctl
diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
index 93a18982..ca7f9140 100644
--- a/lib/i915/intel_memory_region.c
+++ b/lib/i915/intel_memory_region.c
@@ -21,7 +21,11 @@
* IN THE SOFTWARE.
*/
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <limits.h>
+#endif
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/time.h>
diff --git a/lib/i915/perf.c b/lib/i915/perf.c
index d88835ff..beda6b8a 100644
--- a/lib/i915/perf.c
+++ b/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/lib/igt_audio.c b/lib/igt_audio.c
index e0b1bafe..201a39c6 100644
--- a/lib/igt_audio.c
+++ b/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/lib/igt_aux.c b/lib/igt_aux.c
index edb53425..d7e2714f 100644
--- a/lib/igt_aux.c
+++ b/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"
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index c8d487b6..912f36c1 100644
--- a/lib/igt_aux.h
+++ b/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/lib/igt_core.c b/lib/igt_core.c
index e7425326..17d5e013 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -43,9 +43,7 @@
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
-#ifdef __linux__
#include <sys/syscall.h>
-#endif
#include <pthread.h>
#include <sys/utsname.h>
#include <termios.h>
@@ -786,6 +784,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
static void oom_adjust_for_doom(void)
{
+#ifdef __linux__
int fd;
const char always_kill[] = "1000";
@@ -793,7 +792,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
}
/**
@@ -2224,6 +2223,9 @@ bool __igt_fork_helper(struct igt_helper_process *proc)
case 0:
reset_helper_process_list();
oom_adjust_for_doom();
+#ifdef __FreeBSD__
+ raise(SIGTERM);
+#endif
return true;
default:
diff --git a/lib/igt_core.h b/lib/igt_core.h
index aa98e8ed..18e1009d 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -31,7 +31,11 @@
#define IGT_CORE_H
#include <assert.h>
+#ifdef __linux__
#include <byteswap.h>
+#elif defined(__FreeBSD__)
+#include <sys/endian.h>
+#endif
#include <setjmp.h>
#include <stdbool.h>
#include <stdint.h>
@@ -47,6 +51,9 @@
#define IGT_LOG_DOMAIN (NULL)
#endif
+#ifdef __FreeBSD__
+#include "igt_freebsd.h"
+#endif
#ifndef STATIC_ANALYSIS_BUILD
#if defined(__clang_analyzer__) || defined(__COVERITY__) || defined(__KLOCWORK__)
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index a56688a5..fa1e3b69 100644
--- a/lib/igt_debugfs.c
+++ b/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>
diff --git a/lib/igt_device.c b/lib/igt_device.c
index fddfba72..49b77122 100644
--- a/lib/igt_device.c
+++ b/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/lib/igt_device_scan.c b/lib/igt_device_scan.c
index eb6b45b8..6a921d52 100644
--- a/lib/igt_device_scan.c
+++ b/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/lib/igt_eld.c b/lib/igt_eld.c
index ef6625df..e05ad6de 100644
--- a/lib/igt_eld.c
+++ b/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/lib/igt_frame.c b/lib/igt_frame.c
index 45523a79..ab74e678 100644
--- a/lib/igt_frame.c
+++ b/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/lib/igt_freebsd.h b/lib/igt_freebsd.h
new file mode 100644
index 00000000..81ba5c01
--- /dev/null
+++ b/lib/igt_freebsd.h
@@ -0,0 +1,121 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (c) 2022, Jake Freeland <jfree@FreeBSD.org>
+ *
+ * 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.
+ */
+
+#if !defined(IGT_FREEBSD_H) && defined(__FreeBSD__)
+#define IGT_FREEBSD_H
+
+#include <sys/errno.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/sched.h>
+#include <sys/types.h>
+#include <sys/watchdog.h>
+
+#include <pthread.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <unistd.h>
+
+/*
+ * Proper substitutions:
+ * The following macros replace Linux-specific functions
+ * and macros with their FreeBSD equivalents.
+ */
+
+#define __s32 int32_t
+#define __u32 uint32_t
+#define __u64 uint64_t
+
+#define sighandler_t sig_t
+#define ino64_t ino_t
+
+#define jmp_buf sigjmp_buf
+
+#define PTRACE_TRACEME PT_TRACE_ME
+#define PTRACE_ATTACH PT_ATTACH
+#define PTRACE_PEEKDATA PT_READ_D
+#define PTRACE_POKEDATA PT_WRITE_D
+#define PTRACE_DETACH PT_DETACH
+
+#define I2C_RDWR I2CRDWR
+#define I2C_M_RD IIC_M_RD
+#define i2c_msg iic_msg
+#define i2c_rdwr_ioctl_data iic_rdwr_data
+
+#define _IOC_TYPE(nr) (((nr) >> 8) & 255)
+
+#define SYS_getdents64 SYS_freebsd11_getdents
+
+#define mount(src, dest, fstype, flags, data) \
+ mount(fstype, dest, flags, data)
+
+/*
+ * Improper substitutions:
+ * The following macros are temporary replacements for functions
+ * and macros that exist on Linux and do not exist on FreeBSD.
+ */
+
+#define ETIME ETIMEDOUT
+
+#define MAP_POPULATE MAP_PREFAULT_READ
+
+#define MADV_HUGEPAGE MADV_SEQUENTIAL
+#define MADV_DONTFORK MADV_NOSYNC
+
+#define WDIOC_KEEPALIVE WDIOCPATPAT
+
+#define SCHED_RESET_ON_FORK 0
+#define SCHED_IDLE SCHED_OTHER
+
+#define gettid() getpid()
+
+#define pthread_sigqueue(pid, signo, value) \
+ sigqueue(pid, signo, value)
+
+#define signalfd(fd, mask, flags) -ENOSYS
+#define timerfd_create(c, f) -ENOSYS
+#define timerfd_settime(fd, f, n, o) -ENOSYS
+
+/*
+ * Macro conflict resolution.
+ */
+
+#undef ALIGN
+#undef PAGE_SIZE
+
+struct signalfd_siginfo {
+ uint32_t ssi_signo;
+ uint32_t ssi_pid;
+};
+
+struct kmod_module {
+ size_t size;
+};
+
+typedef struct {
+ char state;
+} proc_t;
+
+#endif /* IGT_FREEBSD_H */
diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
index f98dd29f..6596092b 100644
--- a/lib/igt_kmod.h
+++ b/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/lib/igt_kms.c b/lib/igt_kms.c
index 665594aa..532a3aa8 100644
--- a/lib/igt_kms.c
+++ b/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/lib/igt_os.c b/lib/igt_os.c
index bdd5d933..bb6994e1 100644
--- a/lib/igt_os.c
+++ b/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__)
+ 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__)
+ 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/lib/igt_perf.c b/lib/igt_perf.c
index b743859f..11c91c5f 100644
--- a/lib/igt_perf.c
+++ b/lib/igt_perf.c
@@ -4,8 +4,10 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysinfo.h>
#include <sys/sysmacros.h>
+#endif
#include <time.h>
#include <unistd.h>
diff --git a/lib/igt_perf.h b/lib/igt_perf.h
index a8328c70..0cd91386 100644
--- a/lib/igt_perf.h
+++ b/lib/igt_perf.h
@@ -27,10 +27,13 @@
#include <stdint.h>
+#ifdef __linux__
#include <linux/perf_event.h>
+#endif
#include "igt_gt.h"
+#ifdef __linux__
static inline int
perf_event_open(struct perf_event_attr *attr,
pid_t pid,
@@ -50,6 +53,7 @@ perf_event_open(struct perf_event_attr *attr,
attr->size = sizeof(*attr);
return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);
}
+#endif /* __linux__ */
uint64_t igt_perf_type_id(const char *device);
int igt_perf_open(uint64_t type, uint64_t config);
diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 312288d0..1e6e9ed3 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,7 +33,9 @@
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysmacros.h>
+#endif
#include <sys/types.h>
#include <dirent.h>
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 9c307694..a913be4c 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -24,7 +24,9 @@
#include <inttypes.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysmacros.h>
+#endif
#include <sys/mount.h>
#include <errno.h>
#include <stdarg.h>
diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
index 892a7f14..d2381944 100644
--- a/lib/tests/igt_exit_handler.c
+++ b/lib/tests/igt_exit_handler.c
@@ -125,5 +125,9 @@ int main(int argc, char **argv)
internal_assert_wexited(status, IGT_EXIT_SKIP);
status = testfunc(SIG);
+#ifdef __linux__
internal_assert_wsignaled(status, SIGTERM);
+#elif defined(__FreeBSD__)
+ internal_assert(status == 0);
+#endif
}
diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
index d19d0945..c7193b06 100644
--- a/lib/tests/igt_fork.c
+++ b/lib/tests/igt_fork.c
@@ -109,7 +109,7 @@ __noreturn static void igt_fork_timeout_leak(void)
__noreturn static void subtest_leak(void)
{
pid_t *children =
- mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+ mmap(0, 4096, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANON, -1, 0);
const int num_children = 4096 / sizeof(*children);
igt_subtest_init(fake_argc, fake_argv);
diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
index 058f6265..e8183897 100644
--- a/lib/tests/igt_tests_common.h
+++ b/lib/tests/igt_tests_common.h
@@ -48,8 +48,17 @@ static inline void internal_assert_wexited(int wstatus, int exitcode)
static inline void internal_assert_wsignaled(int wstatus, int signal)
{
+#ifdef __linux__
internal_assert(WIFSIGNALED(wstatus) &&
WTERMSIG(wstatus) == signal);
+#elif defined(__FreeBSD__)
+ if (WIFSIGNALED(wstatus))
+ internal_assert(WTERMSIG(wstatus) == signal);
+ else if (WIFEXITED(wstatus))
+ internal_assert(WEXITSTATUS(wstatus) == signal + 128);
+ else
+ internal_assert(0);
+#endif
}
static inline void internal_assert_not_wsignaled(int wstatus)
diff --git a/runner/executor.c b/runner/executor.c
index 964d0063..c54072cf 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -2,7 +2,9 @@
#include <errno.h>
#include <fcntl.h>
#include <glib.h>
+#ifdef __linux__
#include <linux/watchdog.h>
+#endif
#if HAVE_OPING
#include <oping.h>
#endif
@@ -33,6 +35,10 @@
#define KMSG_HEADER "[IGT] "
#define KMSG_WARN 4
+#ifdef __FreeBSD__
+#include <sys/watchdog.h>
+#endif
+
static struct {
int *fds;
size_t num_dogs;
diff --git a/runner/job_list.c b/runner/job_list.c
index 520a98da..6bfa7162 100644
--- a/runner/job_list.c
+++ b/runner/job_list.c
@@ -1,7 +1,12 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <sys/wait.h>
+#include <limits.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
index 938fde8f..42fe1657 100644
--- a/tests/i915/gem_close_race.c
+++ b/tests/i915/gem_close_race.c
@@ -61,7 +61,9 @@ static bool has_softpin;
static uint64_t exec_addr;
static uint64_t data_addr;
+#ifdef __linux__
#define sigev_notify_thread_id _sigev_un._tid
+#endif
static void selfcopy(int fd, uint32_t ctx, uint32_t handle, int loops)
{
diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
index e39b9047..4f05eb18 100644
--- a/tests/i915/gem_mmap_gtt.c
+++ b/tests/i915/gem_mmap_gtt.c
@@ -566,7 +566,7 @@ test_ptrace(int fd)
for (int i = 0; i < sz / sizeof(long); i++) {
long ret;
- ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i);
+ ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i, NULL);
igt_assert_eq_u64(ret, CC);
cpy[i] = ret;
diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
index 5e6b19eb..5781b2fb 100644
--- a/tests/i915/gem_mmap_offset.c
+++ b/tests/i915/gem_mmap_offset.c
@@ -370,7 +370,7 @@ static void test_ptrace(int i915)
for (int i = 0; i < SZ / sizeof(long); i++) {
long ret;
- ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i);
+ ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i, NULL);
igt_assert_eq_u64(ret, CC);
cpy[i] = ret;
diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c
index 4c72157c..9bec4c18 100644
--- a/tests/i915/i915_module_load.c
+++ b/tests/i915/i915_module_load.c
@@ -23,7 +23,9 @@
#include "igt.h"
#include <dirent.h>
#include <sys/utsname.h>
+#ifdef __linux__
#include <linux/limits.h>
+#endif
#include <signal.h>
#include <libgen.h>
#include <signal.h>
diff --git a/tests/i915/i915_pm_backlight.c b/tests/i915/i915_pm_backlight.c
index cafae7f7..c520cf20 100644
--- a/tests/i915/i915_pm_backlight.c
+++ b/tests/i915/i915_pm_backlight.c
@@ -46,6 +46,10 @@ struct context {
#define FADESTEPS 10
#define FADESPEED 100 /* milliseconds between steps */
+#ifdef __FreeBSD__
+#include <libgen.h>
+#endif
+
IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
static int backlight_read(int *result, const char *fname)
diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
index e95875dc..761e76f9 100644
--- a/tests/i915/i915_pm_rpm.c
+++ b/tests/i915/i915_pm_rpm.c
@@ -40,8 +40,10 @@
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
+#endif
#include <drm.h>
@@ -54,6 +56,12 @@
#include "igt_device.h"
#include "igt_edid.h"
+#ifdef __FreeBSD__
+#include <limits.h>
+#include <dev/iicbus/iic.h>
+#define addr slave
+#endif
+
#define MSR_PC8_RES 0x630
#define MSR_PC9_RES 0x631
#define MSR_PC10_RES 0x632
diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
index 3041f1cd..e0e5af78 100644
--- a/tests/kms_content_protection.c
+++ b/tests/kms_content_protection.c
@@ -24,7 +24,9 @@
#include <poll.h>
#include <fcntl.h>
+#ifdef __linux__
#include <sys/epoll.h>
+#endif
#include <sys/stat.h>
#include <libudev.h>
#include "igt.h"
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 0567edea..1127e418 100755
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -45,6 +45,10 @@
#include "i915/gem_create.h"
#include "igt_stats.h"
+#ifdef __FreeBSD__
+#include <sys/consio.h>
+#endif
+
#define TEST_DPMS (1 << 0)
#define TEST_PAN (1 << 3)
diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
index 77521108..cd980c6a 100644
--- a/tests/kms_sysfs_edid_timing.c
+++ b/tests/kms_sysfs_edid_timing.c
@@ -26,6 +26,10 @@
#include <fcntl.h>
#include <sys/stat.h>
+#ifdef __FreeBSD__
+#include <limits.h>
+#endif
+
#define THRESHOLD_PER_CONNECTOR 150
#define THRESHOLD_PER_CONNECTOR_MEAN 140
#define THRESHOLD_ALL_CONNECTORS_MEAN 100
diff --git a/tests/tools_test.c b/tests/tools_test.c
index 237f0433..89a19d11 100644
--- a/tests/tools_test.c
+++ b/tests/tools_test.c
@@ -28,7 +28,11 @@
#include <fcntl.h>
#include <libgen.h>
#include <unistd.h>
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <limits.h>
+#endif
#define TOOLS "../tools/"
diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c
index ad5ee6a6..3e53c6d9 100644
--- a/tools/intel_gvtg_test.c
+++ b/tools/intel_gvtg_test.c
@@ -55,6 +55,10 @@
#include <limits.h>
#include <dirent.h>
+#ifdef __FreeBSD__
+#include <sys/wait.h>
+#endif
+
#define RANDOM(x) (rand() % x)
--
2.37.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility
@ 2022-09-21 4:15 Jake Freeland
0 siblings, 0 replies; 20+ messages in thread
From: Jake Freeland @ 2022-09-21 4:15 UTC (permalink / raw)
To: igt-dev; +Cc: Jake Freeland
Signed-off-by: Jake Freeland <jfree@freebsd.org>
---
benchmarks/gem_exec_tracer.c | 4 ++
benchmarks/gem_syslatency.c | 6 ++
include/linux-uapi/sync_file.h | 5 ++
lib/i915/intel_memory_region.c | 4 ++
lib/i915/perf.c | 2 +
lib/igt_audio.c | 4 ++
lib/igt_aux.c | 2 +
lib/igt_aux.h | 6 +-
lib/igt_core.c | 8 ++-
lib/igt_core.h | 7 ++
lib/igt_debugfs.c | 2 +
lib/igt_device.c | 2 +
lib/igt_device_scan.c | 4 ++
lib/igt_eld.c | 4 ++
lib/igt_frame.c | 4 ++
lib/igt_freebsd.h | 121 +++++++++++++++++++++++++++++++++
lib/igt_kmod.h | 2 +
lib/igt_kms.c | 4 ++
lib/igt_os.c | 19 ++++++
lib/igt_perf.c | 2 +
lib/igt_perf.h | 4 ++
lib/igt_pm.c | 2 +
lib/igt_sysfs.c | 2 +
lib/tests/igt_exit_handler.c | 4 ++
lib/tests/igt_fork.c | 2 +-
lib/tests/igt_tests_common.h | 9 +++
runner/executor.c | 6 ++
runner/job_list.c | 5 ++
tests/i915/gem_close_race.c | 2 +
tests/i915/gem_mmap_gtt.c | 2 +-
tests/i915/gem_mmap_offset.c | 2 +-
tests/i915/i915_module_load.c | 2 +
tests/i915/i915_pm_backlight.c | 4 ++
tests/i915/i915_pm_rpm.c | 8 +++
tests/kms_content_protection.c | 2 +
tests/kms_flip.c | 4 ++
tests/kms_sysfs_edid_timing.c | 4 ++
tests/tools_test.c | 4 ++
tools/intel_gvtg_test.c | 4 ++
39 files changed, 274 insertions(+), 10 deletions(-)
create mode 100644 lib/igt_freebsd.h
diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
index e6973991..7e86473e 100644
--- a/benchmarks/gem_exec_tracer.c
+++ b/benchmarks/gem_exec_tracer.c
@@ -41,6 +41,10 @@
#include "intel_aub.h"
#include "intel_chipset.h"
+#ifdef __FreeBSD__
+#include "igt_freebsd.h"
+#endif
+
static int (*libc_close)(int fd);
static int (*libc_ioctl)(int fd, unsigned long request, void *argp);
diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
index 035ee934..dafc6ac0 100644
--- a/benchmarks/gem_syslatency.c
+++ b/benchmarks/gem_syslatency.c
@@ -42,12 +42,18 @@
#include <limits.h>
#include "drm.h"
+#ifdef __linux__
#include <linux/unistd.h>
+#elif defined(__FreeBSD__)
+#include "igt_freebsd.h"
+#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/include/linux-uapi/sync_file.h b/include/linux-uapi/sync_file.h
index b4f2db00..270c1cbc 100644
--- a/include/linux-uapi/sync_file.h
+++ b/include/linux-uapi/sync_file.h
@@ -12,8 +12,13 @@
#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 "igt_freebsd.h"
+#endif
/**
* struct sync_merge_data - data passed to merge ioctl
diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
index 93a18982..ca7f9140 100644
--- a/lib/i915/intel_memory_region.c
+++ b/lib/i915/intel_memory_region.c
@@ -21,7 +21,11 @@
* IN THE SOFTWARE.
*/
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <limits.h>
+#endif
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/time.h>
diff --git a/lib/i915/perf.c b/lib/i915/perf.c
index d88835ff..beda6b8a 100644
--- a/lib/i915/perf.c
+++ b/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/lib/igt_audio.c b/lib/igt_audio.c
index e0b1bafe..201a39c6 100644
--- a/lib/igt_audio.c
+++ b/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/lib/igt_aux.c b/lib/igt_aux.c
index edb53425..d7e2714f 100644
--- a/lib/igt_aux.c
+++ b/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"
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index c8d487b6..912f36c1 100644
--- a/lib/igt_aux.h
+++ b/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/lib/igt_core.c b/lib/igt_core.c
index e7425326..17d5e013 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -43,9 +43,7 @@
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
-#ifdef __linux__
#include <sys/syscall.h>
-#endif
#include <pthread.h>
#include <sys/utsname.h>
#include <termios.h>
@@ -786,6 +784,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
static void oom_adjust_for_doom(void)
{
+#ifdef __linux__
int fd;
const char always_kill[] = "1000";
@@ -793,7 +792,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
}
/**
@@ -2224,6 +2223,9 @@ bool __igt_fork_helper(struct igt_helper_process *proc)
case 0:
reset_helper_process_list();
oom_adjust_for_doom();
+#ifdef __FreeBSD__
+ raise(SIGTERM);
+#endif
return true;
default:
diff --git a/lib/igt_core.h b/lib/igt_core.h
index aa98e8ed..18e1009d 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -31,7 +31,11 @@
#define IGT_CORE_H
#include <assert.h>
+#ifdef __linux__
#include <byteswap.h>
+#elif defined(__FreeBSD__)
+#include <sys/endian.h>
+#endif
#include <setjmp.h>
#include <stdbool.h>
#include <stdint.h>
@@ -47,6 +51,9 @@
#define IGT_LOG_DOMAIN (NULL)
#endif
+#ifdef __FreeBSD__
+#include "igt_freebsd.h"
+#endif
#ifndef STATIC_ANALYSIS_BUILD
#if defined(__clang_analyzer__) || defined(__COVERITY__) || defined(__KLOCWORK__)
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index a56688a5..fa1e3b69 100644
--- a/lib/igt_debugfs.c
+++ b/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>
diff --git a/lib/igt_device.c b/lib/igt_device.c
index fddfba72..49b77122 100644
--- a/lib/igt_device.c
+++ b/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/lib/igt_device_scan.c b/lib/igt_device_scan.c
index eb6b45b8..6a921d52 100644
--- a/lib/igt_device_scan.c
+++ b/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/lib/igt_eld.c b/lib/igt_eld.c
index ef6625df..e05ad6de 100644
--- a/lib/igt_eld.c
+++ b/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/lib/igt_frame.c b/lib/igt_frame.c
index 45523a79..ab74e678 100644
--- a/lib/igt_frame.c
+++ b/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/lib/igt_freebsd.h b/lib/igt_freebsd.h
new file mode 100644
index 00000000..81ba5c01
--- /dev/null
+++ b/lib/igt_freebsd.h
@@ -0,0 +1,121 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (c) 2022, Jake Freeland <jfree@FreeBSD.org>
+ *
+ * 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.
+ */
+
+#if !defined(IGT_FREEBSD_H) && defined(__FreeBSD__)
+#define IGT_FREEBSD_H
+
+#include <sys/errno.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/sched.h>
+#include <sys/types.h>
+#include <sys/watchdog.h>
+
+#include <pthread.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <unistd.h>
+
+/*
+ * Proper substitutions:
+ * The following macros replace Linux-specific functions
+ * and macros with their FreeBSD equivalents.
+ */
+
+#define __s32 int32_t
+#define __u32 uint32_t
+#define __u64 uint64_t
+
+#define sighandler_t sig_t
+#define ino64_t ino_t
+
+#define jmp_buf sigjmp_buf
+
+#define PTRACE_TRACEME PT_TRACE_ME
+#define PTRACE_ATTACH PT_ATTACH
+#define PTRACE_PEEKDATA PT_READ_D
+#define PTRACE_POKEDATA PT_WRITE_D
+#define PTRACE_DETACH PT_DETACH
+
+#define I2C_RDWR I2CRDWR
+#define I2C_M_RD IIC_M_RD
+#define i2c_msg iic_msg
+#define i2c_rdwr_ioctl_data iic_rdwr_data
+
+#define _IOC_TYPE(nr) (((nr) >> 8) & 255)
+
+#define SYS_getdents64 SYS_freebsd11_getdents
+
+#define mount(src, dest, fstype, flags, data) \
+ mount(fstype, dest, flags, data)
+
+/*
+ * Improper substitutions:
+ * The following macros are temporary replacements for functions
+ * and macros that exist on Linux and do not exist on FreeBSD.
+ */
+
+#define ETIME ETIMEDOUT
+
+#define MAP_POPULATE MAP_PREFAULT_READ
+
+#define MADV_HUGEPAGE MADV_SEQUENTIAL
+#define MADV_DONTFORK MADV_NOSYNC
+
+#define WDIOC_KEEPALIVE WDIOCPATPAT
+
+#define SCHED_RESET_ON_FORK 0
+#define SCHED_IDLE SCHED_OTHER
+
+#define gettid() getpid()
+
+#define pthread_sigqueue(pid, signo, value) \
+ sigqueue(pid, signo, value)
+
+#define signalfd(fd, mask, flags) -ENOSYS
+#define timerfd_create(c, f) -ENOSYS
+#define timerfd_settime(fd, f, n, o) -ENOSYS
+
+/*
+ * Macro conflict resolution.
+ */
+
+#undef ALIGN
+#undef PAGE_SIZE
+
+struct signalfd_siginfo {
+ uint32_t ssi_signo;
+ uint32_t ssi_pid;
+};
+
+struct kmod_module {
+ size_t size;
+};
+
+typedef struct {
+ char state;
+} proc_t;
+
+#endif /* IGT_FREEBSD_H */
diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
index f98dd29f..6596092b 100644
--- a/lib/igt_kmod.h
+++ b/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/lib/igt_kms.c b/lib/igt_kms.c
index 665594aa..532a3aa8 100644
--- a/lib/igt_kms.c
+++ b/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/lib/igt_os.c b/lib/igt_os.c
index bdd5d933..bb6994e1 100644
--- a/lib/igt_os.c
+++ b/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__)
+ 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__)
+ 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/lib/igt_perf.c b/lib/igt_perf.c
index b743859f..11c91c5f 100644
--- a/lib/igt_perf.c
+++ b/lib/igt_perf.c
@@ -4,8 +4,10 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysinfo.h>
#include <sys/sysmacros.h>
+#endif
#include <time.h>
#include <unistd.h>
diff --git a/lib/igt_perf.h b/lib/igt_perf.h
index a8328c70..0cd91386 100644
--- a/lib/igt_perf.h
+++ b/lib/igt_perf.h
@@ -27,10 +27,13 @@
#include <stdint.h>
+#ifdef __linux__
#include <linux/perf_event.h>
+#endif
#include "igt_gt.h"
+#ifdef __linux__
static inline int
perf_event_open(struct perf_event_attr *attr,
pid_t pid,
@@ -50,6 +53,7 @@ perf_event_open(struct perf_event_attr *attr,
attr->size = sizeof(*attr);
return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);
}
+#endif /* __linux__ */
uint64_t igt_perf_type_id(const char *device);
int igt_perf_open(uint64_t type, uint64_t config);
diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 312288d0..1e6e9ed3 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,7 +33,9 @@
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysmacros.h>
+#endif
#include <sys/types.h>
#include <dirent.h>
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 9c307694..a913be4c 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -24,7 +24,9 @@
#include <inttypes.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysmacros.h>
+#endif
#include <sys/mount.h>
#include <errno.h>
#include <stdarg.h>
diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
index 892a7f14..d2381944 100644
--- a/lib/tests/igt_exit_handler.c
+++ b/lib/tests/igt_exit_handler.c
@@ -125,5 +125,9 @@ int main(int argc, char **argv)
internal_assert_wexited(status, IGT_EXIT_SKIP);
status = testfunc(SIG);
+#ifdef __linux__
internal_assert_wsignaled(status, SIGTERM);
+#elif defined(__FreeBSD__)
+ internal_assert(status == 0);
+#endif
}
diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
index d19d0945..c7193b06 100644
--- a/lib/tests/igt_fork.c
+++ b/lib/tests/igt_fork.c
@@ -109,7 +109,7 @@ __noreturn static void igt_fork_timeout_leak(void)
__noreturn static void subtest_leak(void)
{
pid_t *children =
- mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+ mmap(0, 4096, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANON, -1, 0);
const int num_children = 4096 / sizeof(*children);
igt_subtest_init(fake_argc, fake_argv);
diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
index 058f6265..e8183897 100644
--- a/lib/tests/igt_tests_common.h
+++ b/lib/tests/igt_tests_common.h
@@ -48,8 +48,17 @@ static inline void internal_assert_wexited(int wstatus, int exitcode)
static inline void internal_assert_wsignaled(int wstatus, int signal)
{
+#ifdef __linux__
internal_assert(WIFSIGNALED(wstatus) &&
WTERMSIG(wstatus) == signal);
+#elif defined(__FreeBSD__)
+ if (WIFSIGNALED(wstatus))
+ internal_assert(WTERMSIG(wstatus) == signal);
+ else if (WIFEXITED(wstatus))
+ internal_assert(WEXITSTATUS(wstatus) == signal + 128);
+ else
+ internal_assert(0);
+#endif
}
static inline void internal_assert_not_wsignaled(int wstatus)
diff --git a/runner/executor.c b/runner/executor.c
index 964d0063..c54072cf 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -2,7 +2,9 @@
#include <errno.h>
#include <fcntl.h>
#include <glib.h>
+#ifdef __linux__
#include <linux/watchdog.h>
+#endif
#if HAVE_OPING
#include <oping.h>
#endif
@@ -33,6 +35,10 @@
#define KMSG_HEADER "[IGT] "
#define KMSG_WARN 4
+#ifdef __FreeBSD__
+#include <sys/watchdog.h>
+#endif
+
static struct {
int *fds;
size_t num_dogs;
diff --git a/runner/job_list.c b/runner/job_list.c
index 520a98da..6bfa7162 100644
--- a/runner/job_list.c
+++ b/runner/job_list.c
@@ -1,7 +1,12 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <sys/wait.h>
+#include <limits.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
index 938fde8f..42fe1657 100644
--- a/tests/i915/gem_close_race.c
+++ b/tests/i915/gem_close_race.c
@@ -61,7 +61,9 @@ static bool has_softpin;
static uint64_t exec_addr;
static uint64_t data_addr;
+#ifdef __linux__
#define sigev_notify_thread_id _sigev_un._tid
+#endif
static void selfcopy(int fd, uint32_t ctx, uint32_t handle, int loops)
{
diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
index e39b9047..4f05eb18 100644
--- a/tests/i915/gem_mmap_gtt.c
+++ b/tests/i915/gem_mmap_gtt.c
@@ -566,7 +566,7 @@ test_ptrace(int fd)
for (int i = 0; i < sz / sizeof(long); i++) {
long ret;
- ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i);
+ ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i, NULL);
igt_assert_eq_u64(ret, CC);
cpy[i] = ret;
diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
index 5e6b19eb..5781b2fb 100644
--- a/tests/i915/gem_mmap_offset.c
+++ b/tests/i915/gem_mmap_offset.c
@@ -370,7 +370,7 @@ static void test_ptrace(int i915)
for (int i = 0; i < SZ / sizeof(long); i++) {
long ret;
- ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i);
+ ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i, NULL);
igt_assert_eq_u64(ret, CC);
cpy[i] = ret;
diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c
index 4c72157c..9bec4c18 100644
--- a/tests/i915/i915_module_load.c
+++ b/tests/i915/i915_module_load.c
@@ -23,7 +23,9 @@
#include "igt.h"
#include <dirent.h>
#include <sys/utsname.h>
+#ifdef __linux__
#include <linux/limits.h>
+#endif
#include <signal.h>
#include <libgen.h>
#include <signal.h>
diff --git a/tests/i915/i915_pm_backlight.c b/tests/i915/i915_pm_backlight.c
index cafae7f7..c520cf20 100644
--- a/tests/i915/i915_pm_backlight.c
+++ b/tests/i915/i915_pm_backlight.c
@@ -46,6 +46,10 @@ struct context {
#define FADESTEPS 10
#define FADESPEED 100 /* milliseconds between steps */
+#ifdef __FreeBSD__
+#include <libgen.h>
+#endif
+
IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
static int backlight_read(int *result, const char *fname)
diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
index e95875dc..761e76f9 100644
--- a/tests/i915/i915_pm_rpm.c
+++ b/tests/i915/i915_pm_rpm.c
@@ -40,8 +40,10 @@
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
+#endif
#include <drm.h>
@@ -54,6 +56,12 @@
#include "igt_device.h"
#include "igt_edid.h"
+#ifdef __FreeBSD__
+#include <limits.h>
+#include <dev/iicbus/iic.h>
+#define addr slave
+#endif
+
#define MSR_PC8_RES 0x630
#define MSR_PC9_RES 0x631
#define MSR_PC10_RES 0x632
diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
index 3041f1cd..e0e5af78 100644
--- a/tests/kms_content_protection.c
+++ b/tests/kms_content_protection.c
@@ -24,7 +24,9 @@
#include <poll.h>
#include <fcntl.h>
+#ifdef __linux__
#include <sys/epoll.h>
+#endif
#include <sys/stat.h>
#include <libudev.h>
#include "igt.h"
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 0567edea..1127e418 100755
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -45,6 +45,10 @@
#include "i915/gem_create.h"
#include "igt_stats.h"
+#ifdef __FreeBSD__
+#include <sys/consio.h>
+#endif
+
#define TEST_DPMS (1 << 0)
#define TEST_PAN (1 << 3)
diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
index 77521108..cd980c6a 100644
--- a/tests/kms_sysfs_edid_timing.c
+++ b/tests/kms_sysfs_edid_timing.c
@@ -26,6 +26,10 @@
#include <fcntl.h>
#include <sys/stat.h>
+#ifdef __FreeBSD__
+#include <limits.h>
+#endif
+
#define THRESHOLD_PER_CONNECTOR 150
#define THRESHOLD_PER_CONNECTOR_MEAN 140
#define THRESHOLD_ALL_CONNECTORS_MEAN 100
diff --git a/tests/tools_test.c b/tests/tools_test.c
index 237f0433..89a19d11 100644
--- a/tests/tools_test.c
+++ b/tests/tools_test.c
@@ -28,7 +28,11 @@
#include <fcntl.h>
#include <libgen.h>
#include <unistd.h>
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <limits.h>
+#endif
#define TOOLS "../tools/"
diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c
index ad5ee6a6..3e53c6d9 100644
--- a/tools/intel_gvtg_test.c
+++ b/tools/intel_gvtg_test.c
@@ -55,6 +55,10 @@
#include <limits.h>
#include <dirent.h>
+#ifdef __FreeBSD__
+#include <sys/wait.h>
+#endif
+
#define RANDOM(x) (rand() % x)
--
2.37.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility
2022-09-14 20:16 ` Kamil Konieczny
@ 2022-09-18 22:07 ` Jake Freeland
0 siblings, 0 replies; 20+ messages in thread
From: Jake Freeland @ 2022-09-18 22:07 UTC (permalink / raw)
To: Kamil Konieczny, igt-dev, Jake Freeland, Petri Latvala
[-- Attachment #1: Type: text/plain, Size: 39022 bytes --]
Kamil,
Thank you for the patch review. I just submitted a new diff following your
suggestions.
Unfortunately there are some major differences in the way that FreeBSD
handles signals
and return values compared to Linux. This makes directly modifying tests
with #ifdefs necessary in
some cases. I have and will continue to try to keep the tests as untouched
as possible, though.
Thank you,
Jake Freeland
On Wed, Sep 14, 2022 at 3:17 PM Kamil Konieczny <
kamil.konieczny@linux.intel.com> wrote:
> Hi Jake,
>
> On 2022-09-10 at 19:25:30 -0500, Jake Freeland wrote:
> > Signed-off-by: Jake Freeland <jfree@freebsd.org>
> > ---
> > benchmarks/gem_exec_tracer.c | 4 +
> > benchmarks/gem_syslatency.c | 6 ++
> > include/linux-uapi/sync_file.h | 5 ++
> > lib/i915/gem_mman.c | 4 +-
> > lib/i915/intel_memory_region.c | 4 +
> > lib/i915/perf.c | 2 +
> > lib/igt_audio.c | 4 +
> > lib/igt_aux.c | 6 +-
> > lib/igt_aux.h | 6 +-
> > lib/igt_core.c | 8 +-
> > lib/igt_core.h | 5 ++
> > lib/igt_debugfs.c | 2 +
> > lib/igt_device.c | 2 +
> > lib/igt_device_scan.c | 4 +
> > lib/igt_eld.c | 4 +
> > lib/igt_frame.c | 4 +
> > lib/igt_freebsd.h | 123 ++++++++++++++++++++++++++++
> > lib/igt_kmod.h | 2 +
> > lib/igt_kms.c | 4 +
> > lib/igt_os.c | 19 +++++
> > lib/igt_perf.c | 2 +
> > lib/igt_perf.h | 4 +
> > lib/igt_pm.c | 2 +
> > lib/igt_sysfs.c | 2 +
> > lib/igt_vgem.c | 2 +-
> > lib/tests/igt_exit_handler.c | 4 +
> > lib/tests/igt_fork.c | 2 +-
> > lib/tests/igt_tests_common.h | 9 ++
> > runner/executor.c | 6 ++
> > runner/job_list.c | 5 ++
> > tests/i915/gem_close_race.c | 2 +
> > tests/i915/gem_mmap_gtt.c | 24 +++---
> > tests/i915/gem_mmap_offset.c | 16 ++--
> > tests/i915/i915_module_load.c | 2 +
> > tests/i915/i915_pm_backlight.c | 4 +
> > tests/i915/i915_pm_rpm.c | 8 ++
> > tests/kms_content_protection.c | 2 +
> > tests/kms_flip.c | 4 +
> > tests/kms_sysfs_edid_timing.c | 4 +
> > tests/tools_test.c | 10 ++-
> > tools/i915-perf/i915_perf_control.c | 2 +-
> > tools/intel_gvtg_test.c | 4 +
> > 42 files changed, 301 insertions(+), 37 deletions(-)
> > create mode 100644 lib/igt_freebsd.h
> >
> > diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
> > index e6973991..7e86473e 100644
> > --- a/benchmarks/gem_exec_tracer.c
> > +++ b/benchmarks/gem_exec_tracer.c
> > @@ -41,6 +41,10 @@
> > #include "intel_aub.h"
> > #include "intel_chipset.h"
> >
> > +#ifdef __FreeBSD__
> > +#include "igt_freebsd.h"
> > +#endif
> > +
>
> Is it possible to keep changes as minimal as possible ?
> E.g. change as much as you can in libs and/or includes, so you
> can do not touch tests or benchmarks ?
>
> > static int (*libc_close)(int fd);
> > static int (*libc_ioctl)(int fd, unsigned long request, void *argp);
> >
> > diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
> > index 035ee934..dafc6ac0 100644
> > --- a/benchmarks/gem_syslatency.c
> > +++ b/benchmarks/gem_syslatency.c
> > @@ -42,12 +42,18 @@
> > #include <limits.h>
> > #include "drm.h"
> >
> > +#ifdef __linux__
> > #include <linux/unistd.h>
> > +#elif defined(__FreeBSD__)
> > +#include "igt_freebsd.h"
> > +#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/include/linux-uapi/sync_file.h
> b/include/linux-uapi/sync_file.h
> > index b4f2db00..270c1cbc 100644
> > --- a/include/linux-uapi/sync_file.h
> > +++ b/include/linux-uapi/sync_file.h
> > @@ -12,8 +12,13 @@
> > #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 "igt_freebsd.h"
> > +#endif
> >
> > /**
> > * struct sync_merge_data - data passed to merge ioctl
> > diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
> > index aa9ac6f3..0b41ba70 100644
> > --- a/lib/i915/gem_mman.c
> > +++ b/lib/i915/gem_mman.c
> > @@ -118,7 +118,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);
>
> Please move all mmap changes to separate patch, it will improve
> readeability.
>
> > if (ptr == MAP_FAILED)
> > ptr = NULL;
> > else
> > @@ -331,7 +331,7 @@ void *__gem_mmap_offset(int fd, uint32_t handle,
> uint64_t offset, uint64_t size,
> > if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_OFFSET, &arg))
> > return NULL;
> >
> > - ptr = mmap64(0, size, prot, MAP_SHARED, fd, arg.offset + offset);
> > + ptr = mmap(0, size, prot, MAP_SHARED, fd, arg.offset + offset);
> >
> > if (ptr == MAP_FAILED)
> > ptr = NULL;
> > diff --git a/lib/i915/intel_memory_region.c
> b/lib/i915/intel_memory_region.c
> > index 93a18982..ca7f9140 100644
> > --- a/lib/i915/intel_memory_region.c
> > +++ b/lib/i915/intel_memory_region.c
> > @@ -21,7 +21,11 @@
> > * IN THE SOFTWARE.
> > */
> >
> > +#ifdef __linux__
> > #include <linux/limits.h>
> > +#elif defined(__FreeBSD__)
> > +#include <limits.h>
> > +#endif
> > #include <signal.h>
> > #include <sys/ioctl.h>
> > #include <sys/time.h>
> > diff --git a/lib/i915/perf.c b/lib/i915/perf.c
> > index d88835ff..beda6b8a 100644
> > --- a/lib/i915/perf.c
> > +++ b/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/lib/igt_audio.c b/lib/igt_audio.c
> > index e0b1bafe..201a39c6 100644
> > --- a/lib/igt_audio.c
> > +++ b/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/lib/igt_aux.c b/lib/igt_aux.c
> > index edb53425..ba2d52e8 100644
> > --- a/lib/igt_aux.c
> > +++ b/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"
> > @@ -323,10 +325,10 @@ void igt_fork_signal_helper(void)
> > * and we send the signal at exactly the wrong time).
> > */
> > signal(SIGCONT, sig_handler);
> > - setpgrp(); /* define a new process group for the tests */
> > + setpgid(0, 0); /* define a new process group for the tests */
> >
> > igt_fork_helper(&signal_helper) {
> > - setpgrp(); /* Escape from the test process group */
> > + setpgid(0, 0); /* Escape from the test process group */
> >
> > /* Pass along the test process group identifier,
> > * negative pid => send signal to everyone in the group.
> > diff --git a/lib/igt_aux.h b/lib/igt_aux.h
> > index c8d487b6..912f36c1 100644
> > --- a/lib/igt_aux.h
> > +++ b/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/lib/igt_core.c b/lib/igt_core.c
> > index e7425326..17d5e013 100644
> > --- a/lib/igt_core.c
> > +++ b/lib/igt_core.c
> > @@ -43,9 +43,7 @@
> > #include <unistd.h>
> > #include <sys/wait.h>
> > #include <sys/types.h>
> > -#ifdef __linux__
> > #include <sys/syscall.h>
> > -#endif
> > #include <pthread.h>
> > #include <sys/utsname.h>
> > #include <termios.h>
> > @@ -786,6 +784,7 @@ static void print_usage(const char *help_str, bool
> output_on_stderr)
> >
> > static void oom_adjust_for_doom(void)
> > {
> > +#ifdef __linux__
> > int fd;
> > const char always_kill[] = "1000";
> >
> > @@ -793,7 +792,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
> > }
> >
> > /**
> > @@ -2224,6 +2223,9 @@ bool __igt_fork_helper(struct igt_helper_process
> *proc)
> > case 0:
> > reset_helper_process_list();
> > oom_adjust_for_doom();
> > +#ifdef __FreeBSD__
> > + raise(SIGTERM);
> > +#endif
> >
> > return true;
> > default:
> > diff --git a/lib/igt_core.h b/lib/igt_core.h
> > index aa98e8ed..295bb5d9 100644
> > --- a/lib/igt_core.h
> > +++ b/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,9 @@
> > #define IGT_LOG_DOMAIN (NULL)
> > #endif
> >
> > +#ifdef __FreeBSD__
> > +#include "igt_freebsd.h"
> > +#endif
> >
> > #ifndef STATIC_ANALYSIS_BUILD
> > #if defined(__clang_analyzer__) || defined(__COVERITY__) ||
> defined(__KLOCWORK__)
> > diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> > index a56688a5..fa1e3b69 100644
> > --- a/lib/igt_debugfs.c
> > +++ b/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>
> > diff --git a/lib/igt_device.c b/lib/igt_device.c
> > index fddfba72..49b77122 100644
> > --- a/lib/igt_device.c
> > +++ b/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/lib/igt_device_scan.c b/lib/igt_device_scan.c
> > index eb6b45b8..6a921d52 100644
> > --- a/lib/igt_device_scan.c
> > +++ b/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/lib/igt_eld.c b/lib/igt_eld.c
> > index ef6625df..e05ad6de 100644
> > --- a/lib/igt_eld.c
> > +++ b/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/lib/igt_frame.c b/lib/igt_frame.c
> > index 45523a79..ab74e678 100644
> > --- a/lib/igt_frame.c
> > +++ b/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/lib/igt_freebsd.h b/lib/igt_freebsd.h
> > new file mode 100644
> > index 00000000..ea2603e4
> > --- /dev/null
> > +++ b/lib/igt_freebsd.h
> > @@ -0,0 +1,123 @@
> > +/*
> > + * Copyright © 2022 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.
>
> Please use SPDX licence.
>
> > + *
> > + * Authors:
> > + * Jake Freeland <jfree@freebsd.org>
> > + *
> > + */
> > +
> > +#if !defined(IGT_FREEBSD_H) && defined(__FreeBSD__)
> > +#define IGT_FREEBSD_H
> > +
> > +#include <sys/errno.h>
> > +#include <sys/mman.h>
> > +#include <sys/mount.h>
> > +#include <sys/sched.h>
> > +#include <sys/types.h>
> > +#include <sys/watchdog.h>
> > +
> > +#include <pthread.h>
> > +#include <setjmp.h>
> > +#include <signal.h>
> > +#include <unistd.h>
> > +
> > +/*
> > + * Proper substitutions:
> > + * The following macros replace Linux-specific functions
> > + * and macros with their FreeBSD equivalents.
> > + */
> > +
> > +#define __s32 int32_t
> > +#define __u32 uint32_t
> > +#define __u64 uint64_t
> > +
> > +#define sighandler_t sig_t
> > +#define ino64_t ino_t
> > +
> > +#define jmp_buf sigjmp_buf
> > +
> > +#define PTRACE_TRACEME PT_TRACE_ME
> > +#define PTRACE_ATTACH PT_ATTACH
> > +#define PTRACE_PEEKDATA PT_READ_D
> > +#define PTRACE_POKEDATA PT_WRITE_D
> > +#define PTRACE_DETACH PT_DETACH
> > +
> > +#define I2C_RDWR I2CRDWR
> > +#define I2C_M_RD IIC_M_RD
> > +#define i2c_msg iic_msg
> > +#define i2c_rdwr_ioctl_data iic_rdwr_data
> > +
> > +#define _IOC_TYPE(nr) (((nr) >> 8) & 255)
> > +
> > +#define SYS_getdents64 SYS_freebsd11_getdents
> > +
> > +#define mount(src, dest, fstype, flags, data) \
> > + mount(fstype, dest, flags, data)
> > +
> > +/*
> > + * Improper substitutions:
> > + * The following macros are temporary replacements for functions
> > + * and macros that exist on Linux and do not exist on FreeBSD.
> > + */
> > +
> > +#define ETIME ETIMEDOUT
> > +
> > +#define MAP_POPULATE MAP_PREFAULT_READ
> > +
> > +#define MADV_HUGEPAGE MADV_SEQUENTIAL
> > +#define MADV_DONTFORK MADV_NOSYNC
> > +
> > +#define WDIOC_KEEPALIVE WDIOCPATPAT
> > +
> > +#define SCHED_RESET_ON_FORK 0
> > +#define SCHED_IDLE SCHED_OTHER
> > +
> > +#define gettid() getpid()
> > +
> > +#define pthread_sigqueue(pid, signo, value) \
> > + sigqueue(pid, signo, value)
> > +
> > +#define signalfd(fd, mask, flags) -ENOSYS
> > +#define timerfd_create(c, f) -ENOSYS
> > +#define timerfd_settime(fd, f, n, o) -ENOSYS
> > +
> > +/*
> > + * Macro conflict resolution.
> > + */
> > +
> > +#undef ALIGN
> > +#undef PAGE_SIZE
> > +
> > +struct signalfd_siginfo {
> > + uint32_t ssi_signo;
> > + uint32_t ssi_pid;
> > +};
> > +
> > +struct kmod_module {
> > + size_t size;
> > +};
> > +
> > +typedef struct {
> > + char state;
> > +} proc_t;
> > +
> > +#endif /* IGT_FREEBSD_H */
> > diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
> > index f98dd29f..6596092b 100644
> > --- a/lib/igt_kmod.h
> > +++ b/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/lib/igt_kms.c b/lib/igt_kms.c
> > index 1ba3bd2a..f0208c10 100644
> > --- a/lib/igt_kms.c
> > +++ b/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/lib/igt_os.c b/lib/igt_os.c
> > index bdd5d933..ae426e3a 100644
> > --- a/lib/igt_os.c
> > +++ b/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 */
> -------------------------------- ^
> You do not need to repeat it here.
>
> > + 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 */
> -------------------------------- ^
> Same here.
>
> Regards,
> Kamil
>
>
> > + 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/lib/igt_perf.c b/lib/igt_perf.c
> > index b743859f..11c91c5f 100644
> > --- a/lib/igt_perf.c
> > +++ b/lib/igt_perf.c
> > @@ -4,8 +4,10 @@
> > #include <stdlib.h>
> > #include <string.h>
> > #include <sys/stat.h>
> > +#ifdef __linux__
> > #include <sys/sysinfo.h>
> > #include <sys/sysmacros.h>
> > +#endif
> > #include <time.h>
> > #include <unistd.h>
> >
> > diff --git a/lib/igt_perf.h b/lib/igt_perf.h
> > index a8328c70..0cd91386 100644
> > --- a/lib/igt_perf.h
> > +++ b/lib/igt_perf.h
> > @@ -27,10 +27,13 @@
> >
> > #include <stdint.h>
> >
> > +#ifdef __linux__
> > #include <linux/perf_event.h>
> > +#endif
> >
> > #include "igt_gt.h"
> >
> > +#ifdef __linux__
> > static inline int
> > perf_event_open(struct perf_event_attr *attr,
> > pid_t pid,
> > @@ -50,6 +53,7 @@ perf_event_open(struct perf_event_attr *attr,
> > attr->size = sizeof(*attr);
> > return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd,
> flags);
> > }
> > +#endif /* __linux__ */
> >
> > uint64_t igt_perf_type_id(const char *device);
> > int igt_perf_open(uint64_t type, uint64_t config);
> > diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> > index 99251b40..a6036e03 100644
> > --- a/lib/igt_pm.c
> > +++ b/lib/igt_pm.c
> > @@ -33,7 +33,9 @@
> > #include <string.h>
> > #include <unistd.h>
> > #include <sys/stat.h>
> > +#ifdef __linux__
> > #include <sys/sysmacros.h>
> > +#endif
> > #include <sys/types.h>
> > #include <dirent.h>
> >
> > diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
> > index 9c307694..a913be4c 100644
> > --- a/lib/igt_sysfs.c
> > +++ b/lib/igt_sysfs.c
> > @@ -24,7 +24,9 @@
> >
> > #include <inttypes.h>
> > #include <sys/stat.h>
> > +#ifdef __linux__
> > #include <sys/sysmacros.h>
> > +#endif
> > #include <sys/mount.h>
> > #include <errno.h>
> > #include <stdarg.h>
> > diff --git a/lib/igt_vgem.c b/lib/igt_vgem.c
> > index 7f933b23..468383c7 100644
> > --- a/lib/igt_vgem.c
> > +++ b/lib/igt_vgem.c
> > @@ -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;
> >
> > diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
> > index 892a7f14..d2381944 100644
> > --- a/lib/tests/igt_exit_handler.c
> > +++ b/lib/tests/igt_exit_handler.c
> > @@ -125,5 +125,9 @@ int main(int argc, char **argv)
> > internal_assert_wexited(status, IGT_EXIT_SKIP);
> >
> > status = testfunc(SIG);
> > +#ifdef __linux__
> > internal_assert_wsignaled(status, SIGTERM);
> > +#elif defined(__FreeBSD__)
> > + internal_assert(status == 0);
> > +#endif
> > }
> > diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
> > index d19d0945..c7193b06 100644
> > --- a/lib/tests/igt_fork.c
> > +++ b/lib/tests/igt_fork.c
> > @@ -109,7 +109,7 @@ __noreturn static void igt_fork_timeout_leak(void)
> > __noreturn static void subtest_leak(void)
> > {
> > pid_t *children =
> > - mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
> > + mmap(0, 4096, PROT_WRITE | PROT_READ, MAP_SHARED |
> MAP_ANON, -1, 0);
> > const int num_children = 4096 / sizeof(*children);
> >
> > igt_subtest_init(fake_argc, fake_argv);
> > diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
> > index 058f6265..e8183897 100644
> > --- a/lib/tests/igt_tests_common.h
> > +++ b/lib/tests/igt_tests_common.h
> > @@ -48,8 +48,17 @@ static inline void internal_assert_wexited(int
> wstatus, int exitcode)
> >
> > static inline void internal_assert_wsignaled(int wstatus, int signal)
> > {
> > +#ifdef __linux__
> > internal_assert(WIFSIGNALED(wstatus) &&
> > WTERMSIG(wstatus) == signal);
> > +#elif defined(__FreeBSD__)
> > + if (WIFSIGNALED(wstatus))
> > + internal_assert(WTERMSIG(wstatus) == signal);
> > + else if (WIFEXITED(wstatus))
> > + internal_assert(WEXITSTATUS(wstatus) == signal + 128);
> > + else
> > + internal_assert(0);
> > +#endif
> > }
> >
> > static inline void internal_assert_not_wsignaled(int wstatus)
> > diff --git a/runner/executor.c b/runner/executor.c
> > index 964d0063..c54072cf 100644
> > --- a/runner/executor.c
> > +++ b/runner/executor.c
> > @@ -2,7 +2,9 @@
> > #include <errno.h>
> > #include <fcntl.h>
> > #include <glib.h>
> > +#ifdef __linux__
> > #include <linux/watchdog.h>
> > +#endif
> > #if HAVE_OPING
> > #include <oping.h>
> > #endif
> > @@ -33,6 +35,10 @@
> > #define KMSG_HEADER "[IGT] "
> > #define KMSG_WARN 4
> >
> > +#ifdef __FreeBSD__
> > +#include <sys/watchdog.h>
> > +#endif
> > +
> > static struct {
> > int *fds;
> > size_t num_dogs;
> > diff --git a/runner/job_list.c b/runner/job_list.c
> > index 520a98da..6bfa7162 100644
> > --- a/runner/job_list.c
> > +++ b/runner/job_list.c
> > @@ -1,7 +1,12 @@
> > #include <ctype.h>
> > #include <errno.h>
> > #include <fcntl.h>
> > +#ifdef __linux__
> > #include <linux/limits.h>
> > +#elif defined(__FreeBSD__)
> > +#include <sys/wait.h>
> > +#include <limits.h>
> > +#endif
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <string.h>
> > diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
> > index 938fde8f..42fe1657 100644
> > --- a/tests/i915/gem_close_race.c
> > +++ b/tests/i915/gem_close_race.c
> > @@ -61,7 +61,9 @@ static bool has_softpin;
> > static uint64_t exec_addr;
> > static uint64_t data_addr;
> >
> > +#ifdef __linux__
> > #define sigev_notify_thread_id _sigev_un._tid
> > +#endif
> >
> > static void selfcopy(int fd, uint32_t ctx, uint32_t handle, int loops)
> > {
> > diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
> > index e39b9047..683eaf16 100644
> > --- a/tests/i915/gem_mmap_gtt.c
> > +++ b/tests/i915/gem_mmap_gtt.c
> > @@ -113,11 +113,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);
> >
> > @@ -128,7 +128,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));
> > }
> >
> > @@ -159,11 +159,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);
> >
> > @@ -384,13 +384,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);
> > }
> >
> > @@ -400,7 +400,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) {
> > @@ -418,7 +418,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) {
> > @@ -444,7 +444,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) {
> > @@ -469,7 +469,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) {
> > @@ -566,7 +566,7 @@ test_ptrace(int fd)
> > for (int i = 0; i < sz / sizeof(long); i++) {
> > long ret;
> >
> > - ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i);
> > + ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i, NULL);
> > igt_assert_eq_u64(ret, CC);
> > cpy[i] = ret;
> >
> > diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
> > index 5e6b19eb..0933ed94 100644
> > --- a/tests/i915/gem_mmap_offset.c
> > +++ b/tests/i915/gem_mmap_offset.c
> > @@ -66,7 +66,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
> > @@ -214,12 +214,12 @@ 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);
> >
> > @@ -237,13 +237,13 @@ static void 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);
> > }
> > }
> > @@ -370,7 +370,7 @@ static void test_ptrace(int i915)
> > for (int i = 0; i < SZ / sizeof(long); i++) {
> > long ret;
> >
> > - ret = ptrace(PTRACE_PEEKDATA, pid, ptr +
> i);
> > + ret = ptrace(PTRACE_PEEKDATA, pid, ptr +
> i, NULL);
> > igt_assert_eq_u64(ret, CC);
> > cpy[i] = ret;
> >
> > @@ -401,7 +401,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) {
> > @@ -420,7 +420,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) {
> > diff --git a/tests/i915/i915_module_load.c
> b/tests/i915/i915_module_load.c
> > index 4c72157c..9bec4c18 100644
> > --- a/tests/i915/i915_module_load.c
> > +++ b/tests/i915/i915_module_load.c
> > @@ -23,7 +23,9 @@
> > #include "igt.h"
> > #include <dirent.h>
> > #include <sys/utsname.h>
> > +#ifdef __linux__
> > #include <linux/limits.h>
> > +#endif
> > #include <signal.h>
> > #include <libgen.h>
> > #include <signal.h>
> > diff --git a/tests/i915/i915_pm_backlight.c
> b/tests/i915/i915_pm_backlight.c
> > index cafae7f7..c520cf20 100644
> > --- a/tests/i915/i915_pm_backlight.c
> > +++ b/tests/i915/i915_pm_backlight.c
> > @@ -46,6 +46,10 @@ struct context {
> > #define FADESTEPS 10
> > #define FADESPEED 100 /* milliseconds between steps */
> >
> > +#ifdef __FreeBSD__
> > +#include <libgen.h>
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
> >
> > static int backlight_read(int *result, const char *fname)
> > diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
> > index e95875dc..761e76f9 100644
> > --- a/tests/i915/i915_pm_rpm.c
> > +++ b/tests/i915/i915_pm_rpm.c
> > @@ -40,8 +40,10 @@
> > #include <sys/mman.h>
> > #include <sys/types.h>
> > #include <sys/stat.h>
> > +#ifdef __linux__
> > #include <linux/i2c.h>
> > #include <linux/i2c-dev.h>
> > +#endif
> >
> > #include <drm.h>
> >
> > @@ -54,6 +56,12 @@
> > #include "igt_device.h"
> > #include "igt_edid.h"
> >
> > +#ifdef __FreeBSD__
> > +#include <limits.h>
> > +#include <dev/iicbus/iic.h>
> > +#define addr slave
> > +#endif
> > +
> > #define MSR_PC8_RES 0x630
> > #define MSR_PC9_RES 0x631
> > #define MSR_PC10_RES 0x632
> > diff --git a/tests/kms_content_protection.c
> b/tests/kms_content_protection.c
> > index 3041f1cd..e0e5af78 100644
> > --- a/tests/kms_content_protection.c
> > +++ b/tests/kms_content_protection.c
> > @@ -24,7 +24,9 @@
> >
> > #include <poll.h>
> > #include <fcntl.h>
> > +#ifdef __linux__
> > #include <sys/epoll.h>
> > +#endif
> > #include <sys/stat.h>
> > #include <libudev.h>
> > #include "igt.h"
> > diff --git a/tests/kms_flip.c b/tests/kms_flip.c
> > index 0567edea..1127e418 100755
> > --- a/tests/kms_flip.c
> > +++ b/tests/kms_flip.c
> > @@ -45,6 +45,10 @@
> > #include "i915/gem_create.h"
> > #include "igt_stats.h"
> >
> > +#ifdef __FreeBSD__
> > +#include <sys/consio.h>
> > +#endif
> > +
> > #define TEST_DPMS (1 << 0)
> >
> > #define TEST_PAN (1 << 3)
> > diff --git a/tests/kms_sysfs_edid_timing.c
> b/tests/kms_sysfs_edid_timing.c
> > index 77521108..cd980c6a 100644
> > --- a/tests/kms_sysfs_edid_timing.c
> > +++ b/tests/kms_sysfs_edid_timing.c
> > @@ -26,6 +26,10 @@
> > #include <fcntl.h>
> > #include <sys/stat.h>
> >
> > +#ifdef __FreeBSD__
> > +#include <limits.h>
> > +#endif
> > +
> > #define THRESHOLD_PER_CONNECTOR 150
> > #define THRESHOLD_PER_CONNECTOR_MEAN 140
> > #define THRESHOLD_ALL_CONNECTORS_MEAN 100
> > diff --git a/tests/tools_test.c b/tests/tools_test.c
> > index 237f0433..d0684d57 100644
> > --- a/tests/tools_test.c
> > +++ b/tests/tools_test.c
> > @@ -28,7 +28,11 @@
> > #include <fcntl.h>
> > #include <libgen.h>
> > #include <unistd.h>
> > +#ifdef __linux__
> > #include <linux/limits.h>
> > +#elif defined(__FreeBSD__)
> > +#include <limits.h>
> > +#endif
> >
> > #define TOOLS "../tools/"
> >
> > @@ -65,7 +69,7 @@ static bool chdir_to_tools_dir(void)
> > char path[PATH_MAX];
> > char *cwd;
> >
> > - cwd = get_current_dir_name();
> > + cwd = getcwd(NULL, 0);
> > igt_info("Current working directory: %s\n", cwd);
> > free(cwd);
> >
> > @@ -83,7 +87,7 @@ static bool chdir_to_tools_dir(void)
> > chdir(dirname(path));
> > }
> >
> > - cwd = get_current_dir_name();
> > + cwd = getcwd(NULL, 0);
> > igt_info("Current working directory: %s\n", cwd);
> > free(cwd);
> >
> > @@ -99,7 +103,7 @@ igt_main
> >
> > igt_require_f(chdir_to_tools_dir(),
> > "Unable to determine the tools directory,
> expecting them in $cwd/" TOOLS " or $path/" TOOLS "\n");
> > - path = get_current_dir_name();
> > + path = getcwd(NULL, 0);
> > igt_info("Using tools from %s\n", path);
> > free(path);
> > }
> > diff --git a/tools/i915-perf/i915_perf_control.c
> b/tools/i915-perf/i915_perf_control.c
> > index be5996c0..f7db2f5c 100644
> > --- a/tools/i915-perf/i915_perf_control.c
> > +++ b/tools/i915-perf/i915_perf_control.c
> > @@ -102,7 +102,7 @@ main(int argc, char *argv[])
> >
> > fwrite(data, total_len, 1, command_fifo_file);
> > } else {
> > - char *cwd = get_current_dir_name();
> > + char *cwd = getcwd(NULL, 0);
> > uint32_t path_len = strlen(cwd) + 1 +
> strlen(dump_file) + 1;
> > uint32_t total_len = sizeof(struct
> recorder_command_base) + path_len;
> > struct {
> > diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c
> > index ad5ee6a6..3e53c6d9 100644
> > --- a/tools/intel_gvtg_test.c
> > +++ b/tools/intel_gvtg_test.c
> > @@ -55,6 +55,10 @@
> > #include <limits.h>
> > #include <dirent.h>
> >
> > +#ifdef __FreeBSD__
> > +#include <sys/wait.h>
> > +#endif
> > +
> > #define RANDOM(x) (rand() % x)
> >
> >
> > --
> > 2.37.3
> >
>
[-- Attachment #2: Type: text/html, Size: 49315 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility
@ 2022-09-18 22:00 Jake Freeland
0 siblings, 0 replies; 20+ messages in thread
From: Jake Freeland @ 2022-09-18 22:00 UTC (permalink / raw)
To: igt-dev, petri.latvala, kamil.konieczny; +Cc: Jake Freeland
Signed-off-by: Jake Freeland <jfree@freebsd.org>
---
benchmarks/gem_exec_tracer.c | 4 ++
benchmarks/gem_syslatency.c | 6 ++
include/linux-uapi/sync_file.h | 5 ++
lib/i915/intel_memory_region.c | 4 ++
lib/i915/perf.c | 2 +
lib/igt_audio.c | 4 ++
lib/igt_aux.c | 2 +
lib/igt_aux.h | 6 +-
lib/igt_core.c | 8 ++-
lib/igt_core.h | 5 ++
lib/igt_debugfs.c | 2 +
lib/igt_device.c | 2 +
lib/igt_device_scan.c | 4 ++
lib/igt_eld.c | 4 ++
lib/igt_frame.c | 4 ++
lib/igt_freebsd.h | 121 +++++++++++++++++++++++++++++++++
lib/igt_kmod.h | 2 +
lib/igt_kms.c | 4 ++
lib/igt_os.c | 19 ++++++
lib/igt_perf.c | 2 +
lib/igt_perf.h | 4 ++
lib/igt_pm.c | 2 +
lib/igt_sysfs.c | 2 +
lib/tests/igt_exit_handler.c | 4 ++
lib/tests/igt_fork.c | 2 +-
lib/tests/igt_tests_common.h | 9 +++
runner/executor.c | 6 ++
runner/job_list.c | 5 ++
tests/i915/gem_close_race.c | 2 +
tests/i915/gem_mmap_gtt.c | 2 +-
tests/i915/gem_mmap_offset.c | 2 +-
tests/i915/i915_module_load.c | 2 +
tests/i915/i915_pm_backlight.c | 4 ++
tests/i915/i915_pm_rpm.c | 8 +++
tests/kms_content_protection.c | 2 +
tests/kms_flip.c | 4 ++
tests/kms_sysfs_edid_timing.c | 4 ++
tests/tools_test.c | 4 ++
tools/intel_gvtg_test.c | 4 ++
39 files changed, 272 insertions(+), 10 deletions(-)
create mode 100644 lib/igt_freebsd.h
diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
index e6973991..7e86473e 100644
--- a/benchmarks/gem_exec_tracer.c
+++ b/benchmarks/gem_exec_tracer.c
@@ -41,6 +41,10 @@
#include "intel_aub.h"
#include "intel_chipset.h"
+#ifdef __FreeBSD__
+#include "igt_freebsd.h"
+#endif
+
static int (*libc_close)(int fd);
static int (*libc_ioctl)(int fd, unsigned long request, void *argp);
diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
index 035ee934..dafc6ac0 100644
--- a/benchmarks/gem_syslatency.c
+++ b/benchmarks/gem_syslatency.c
@@ -42,12 +42,18 @@
#include <limits.h>
#include "drm.h"
+#ifdef __linux__
#include <linux/unistd.h>
+#elif defined(__FreeBSD__)
+#include "igt_freebsd.h"
+#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/include/linux-uapi/sync_file.h b/include/linux-uapi/sync_file.h
index b4f2db00..270c1cbc 100644
--- a/include/linux-uapi/sync_file.h
+++ b/include/linux-uapi/sync_file.h
@@ -12,8 +12,13 @@
#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 "igt_freebsd.h"
+#endif
/**
* struct sync_merge_data - data passed to merge ioctl
diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
index 93a18982..ca7f9140 100644
--- a/lib/i915/intel_memory_region.c
+++ b/lib/i915/intel_memory_region.c
@@ -21,7 +21,11 @@
* IN THE SOFTWARE.
*/
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <limits.h>
+#endif
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/time.h>
diff --git a/lib/i915/perf.c b/lib/i915/perf.c
index d88835ff..beda6b8a 100644
--- a/lib/i915/perf.c
+++ b/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/lib/igt_audio.c b/lib/igt_audio.c
index e0b1bafe..201a39c6 100644
--- a/lib/igt_audio.c
+++ b/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/lib/igt_aux.c b/lib/igt_aux.c
index edb53425..d7e2714f 100644
--- a/lib/igt_aux.c
+++ b/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"
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index c8d487b6..912f36c1 100644
--- a/lib/igt_aux.h
+++ b/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/lib/igt_core.c b/lib/igt_core.c
index e7425326..17d5e013 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -43,9 +43,7 @@
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
-#ifdef __linux__
#include <sys/syscall.h>
-#endif
#include <pthread.h>
#include <sys/utsname.h>
#include <termios.h>
@@ -786,6 +784,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
static void oom_adjust_for_doom(void)
{
+#ifdef __linux__
int fd;
const char always_kill[] = "1000";
@@ -793,7 +792,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
}
/**
@@ -2224,6 +2223,9 @@ bool __igt_fork_helper(struct igt_helper_process *proc)
case 0:
reset_helper_process_list();
oom_adjust_for_doom();
+#ifdef __FreeBSD__
+ raise(SIGTERM);
+#endif
return true;
default:
diff --git a/lib/igt_core.h b/lib/igt_core.h
index aa98e8ed..295bb5d9 100644
--- a/lib/igt_core.h
+++ b/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,9 @@
#define IGT_LOG_DOMAIN (NULL)
#endif
+#ifdef __FreeBSD__
+#include "igt_freebsd.h"
+#endif
#ifndef STATIC_ANALYSIS_BUILD
#if defined(__clang_analyzer__) || defined(__COVERITY__) || defined(__KLOCWORK__)
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index a56688a5..fa1e3b69 100644
--- a/lib/igt_debugfs.c
+++ b/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>
diff --git a/lib/igt_device.c b/lib/igt_device.c
index fddfba72..49b77122 100644
--- a/lib/igt_device.c
+++ b/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/lib/igt_device_scan.c b/lib/igt_device_scan.c
index eb6b45b8..6a921d52 100644
--- a/lib/igt_device_scan.c
+++ b/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/lib/igt_eld.c b/lib/igt_eld.c
index ef6625df..e05ad6de 100644
--- a/lib/igt_eld.c
+++ b/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/lib/igt_frame.c b/lib/igt_frame.c
index 45523a79..ab74e678 100644
--- a/lib/igt_frame.c
+++ b/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/lib/igt_freebsd.h b/lib/igt_freebsd.h
new file mode 100644
index 00000000..81ba5c01
--- /dev/null
+++ b/lib/igt_freebsd.h
@@ -0,0 +1,121 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (c) 2022, Jake Freeland <jfree@FreeBSD.org>
+ *
+ * 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.
+ */
+
+#if !defined(IGT_FREEBSD_H) && defined(__FreeBSD__)
+#define IGT_FREEBSD_H
+
+#include <sys/errno.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/sched.h>
+#include <sys/types.h>
+#include <sys/watchdog.h>
+
+#include <pthread.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <unistd.h>
+
+/*
+ * Proper substitutions:
+ * The following macros replace Linux-specific functions
+ * and macros with their FreeBSD equivalents.
+ */
+
+#define __s32 int32_t
+#define __u32 uint32_t
+#define __u64 uint64_t
+
+#define sighandler_t sig_t
+#define ino64_t ino_t
+
+#define jmp_buf sigjmp_buf
+
+#define PTRACE_TRACEME PT_TRACE_ME
+#define PTRACE_ATTACH PT_ATTACH
+#define PTRACE_PEEKDATA PT_READ_D
+#define PTRACE_POKEDATA PT_WRITE_D
+#define PTRACE_DETACH PT_DETACH
+
+#define I2C_RDWR I2CRDWR
+#define I2C_M_RD IIC_M_RD
+#define i2c_msg iic_msg
+#define i2c_rdwr_ioctl_data iic_rdwr_data
+
+#define _IOC_TYPE(nr) (((nr) >> 8) & 255)
+
+#define SYS_getdents64 SYS_freebsd11_getdents
+
+#define mount(src, dest, fstype, flags, data) \
+ mount(fstype, dest, flags, data)
+
+/*
+ * Improper substitutions:
+ * The following macros are temporary replacements for functions
+ * and macros that exist on Linux and do not exist on FreeBSD.
+ */
+
+#define ETIME ETIMEDOUT
+
+#define MAP_POPULATE MAP_PREFAULT_READ
+
+#define MADV_HUGEPAGE MADV_SEQUENTIAL
+#define MADV_DONTFORK MADV_NOSYNC
+
+#define WDIOC_KEEPALIVE WDIOCPATPAT
+
+#define SCHED_RESET_ON_FORK 0
+#define SCHED_IDLE SCHED_OTHER
+
+#define gettid() getpid()
+
+#define pthread_sigqueue(pid, signo, value) \
+ sigqueue(pid, signo, value)
+
+#define signalfd(fd, mask, flags) -ENOSYS
+#define timerfd_create(c, f) -ENOSYS
+#define timerfd_settime(fd, f, n, o) -ENOSYS
+
+/*
+ * Macro conflict resolution.
+ */
+
+#undef ALIGN
+#undef PAGE_SIZE
+
+struct signalfd_siginfo {
+ uint32_t ssi_signo;
+ uint32_t ssi_pid;
+};
+
+struct kmod_module {
+ size_t size;
+};
+
+typedef struct {
+ char state;
+} proc_t;
+
+#endif /* IGT_FREEBSD_H */
diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
index f98dd29f..6596092b 100644
--- a/lib/igt_kmod.h
+++ b/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/lib/igt_kms.c b/lib/igt_kms.c
index 665594aa..532a3aa8 100644
--- a/lib/igt_kms.c
+++ b/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/lib/igt_os.c b/lib/igt_os.c
index bdd5d933..bb6994e1 100644
--- a/lib/igt_os.c
+++ b/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__)
+ 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__)
+ 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/lib/igt_perf.c b/lib/igt_perf.c
index b743859f..11c91c5f 100644
--- a/lib/igt_perf.c
+++ b/lib/igt_perf.c
@@ -4,8 +4,10 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysinfo.h>
#include <sys/sysmacros.h>
+#endif
#include <time.h>
#include <unistd.h>
diff --git a/lib/igt_perf.h b/lib/igt_perf.h
index a8328c70..0cd91386 100644
--- a/lib/igt_perf.h
+++ b/lib/igt_perf.h
@@ -27,10 +27,13 @@
#include <stdint.h>
+#ifdef __linux__
#include <linux/perf_event.h>
+#endif
#include "igt_gt.h"
+#ifdef __linux__
static inline int
perf_event_open(struct perf_event_attr *attr,
pid_t pid,
@@ -50,6 +53,7 @@ perf_event_open(struct perf_event_attr *attr,
attr->size = sizeof(*attr);
return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);
}
+#endif /* __linux__ */
uint64_t igt_perf_type_id(const char *device);
int igt_perf_open(uint64_t type, uint64_t config);
diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 312288d0..1e6e9ed3 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,7 +33,9 @@
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysmacros.h>
+#endif
#include <sys/types.h>
#include <dirent.h>
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 9c307694..a913be4c 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -24,7 +24,9 @@
#include <inttypes.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysmacros.h>
+#endif
#include <sys/mount.h>
#include <errno.h>
#include <stdarg.h>
diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
index 892a7f14..d2381944 100644
--- a/lib/tests/igt_exit_handler.c
+++ b/lib/tests/igt_exit_handler.c
@@ -125,5 +125,9 @@ int main(int argc, char **argv)
internal_assert_wexited(status, IGT_EXIT_SKIP);
status = testfunc(SIG);
+#ifdef __linux__
internal_assert_wsignaled(status, SIGTERM);
+#elif defined(__FreeBSD__)
+ internal_assert(status == 0);
+#endif
}
diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
index d19d0945..c7193b06 100644
--- a/lib/tests/igt_fork.c
+++ b/lib/tests/igt_fork.c
@@ -109,7 +109,7 @@ __noreturn static void igt_fork_timeout_leak(void)
__noreturn static void subtest_leak(void)
{
pid_t *children =
- mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+ mmap(0, 4096, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANON, -1, 0);
const int num_children = 4096 / sizeof(*children);
igt_subtest_init(fake_argc, fake_argv);
diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
index 058f6265..e8183897 100644
--- a/lib/tests/igt_tests_common.h
+++ b/lib/tests/igt_tests_common.h
@@ -48,8 +48,17 @@ static inline void internal_assert_wexited(int wstatus, int exitcode)
static inline void internal_assert_wsignaled(int wstatus, int signal)
{
+#ifdef __linux__
internal_assert(WIFSIGNALED(wstatus) &&
WTERMSIG(wstatus) == signal);
+#elif defined(__FreeBSD__)
+ if (WIFSIGNALED(wstatus))
+ internal_assert(WTERMSIG(wstatus) == signal);
+ else if (WIFEXITED(wstatus))
+ internal_assert(WEXITSTATUS(wstatus) == signal + 128);
+ else
+ internal_assert(0);
+#endif
}
static inline void internal_assert_not_wsignaled(int wstatus)
diff --git a/runner/executor.c b/runner/executor.c
index 964d0063..c54072cf 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -2,7 +2,9 @@
#include <errno.h>
#include <fcntl.h>
#include <glib.h>
+#ifdef __linux__
#include <linux/watchdog.h>
+#endif
#if HAVE_OPING
#include <oping.h>
#endif
@@ -33,6 +35,10 @@
#define KMSG_HEADER "[IGT] "
#define KMSG_WARN 4
+#ifdef __FreeBSD__
+#include <sys/watchdog.h>
+#endif
+
static struct {
int *fds;
size_t num_dogs;
diff --git a/runner/job_list.c b/runner/job_list.c
index 520a98da..6bfa7162 100644
--- a/runner/job_list.c
+++ b/runner/job_list.c
@@ -1,7 +1,12 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <sys/wait.h>
+#include <limits.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
index 938fde8f..42fe1657 100644
--- a/tests/i915/gem_close_race.c
+++ b/tests/i915/gem_close_race.c
@@ -61,7 +61,9 @@ static bool has_softpin;
static uint64_t exec_addr;
static uint64_t data_addr;
+#ifdef __linux__
#define sigev_notify_thread_id _sigev_un._tid
+#endif
static void selfcopy(int fd, uint32_t ctx, uint32_t handle, int loops)
{
diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
index e39b9047..4f05eb18 100644
--- a/tests/i915/gem_mmap_gtt.c
+++ b/tests/i915/gem_mmap_gtt.c
@@ -566,7 +566,7 @@ test_ptrace(int fd)
for (int i = 0; i < sz / sizeof(long); i++) {
long ret;
- ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i);
+ ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i, NULL);
igt_assert_eq_u64(ret, CC);
cpy[i] = ret;
diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
index 5e6b19eb..5781b2fb 100644
--- a/tests/i915/gem_mmap_offset.c
+++ b/tests/i915/gem_mmap_offset.c
@@ -370,7 +370,7 @@ static void test_ptrace(int i915)
for (int i = 0; i < SZ / sizeof(long); i++) {
long ret;
- ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i);
+ ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i, NULL);
igt_assert_eq_u64(ret, CC);
cpy[i] = ret;
diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c
index 4c72157c..9bec4c18 100644
--- a/tests/i915/i915_module_load.c
+++ b/tests/i915/i915_module_load.c
@@ -23,7 +23,9 @@
#include "igt.h"
#include <dirent.h>
#include <sys/utsname.h>
+#ifdef __linux__
#include <linux/limits.h>
+#endif
#include <signal.h>
#include <libgen.h>
#include <signal.h>
diff --git a/tests/i915/i915_pm_backlight.c b/tests/i915/i915_pm_backlight.c
index cafae7f7..c520cf20 100644
--- a/tests/i915/i915_pm_backlight.c
+++ b/tests/i915/i915_pm_backlight.c
@@ -46,6 +46,10 @@ struct context {
#define FADESTEPS 10
#define FADESPEED 100 /* milliseconds between steps */
+#ifdef __FreeBSD__
+#include <libgen.h>
+#endif
+
IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
static int backlight_read(int *result, const char *fname)
diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
index e95875dc..761e76f9 100644
--- a/tests/i915/i915_pm_rpm.c
+++ b/tests/i915/i915_pm_rpm.c
@@ -40,8 +40,10 @@
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
+#endif
#include <drm.h>
@@ -54,6 +56,12 @@
#include "igt_device.h"
#include "igt_edid.h"
+#ifdef __FreeBSD__
+#include <limits.h>
+#include <dev/iicbus/iic.h>
+#define addr slave
+#endif
+
#define MSR_PC8_RES 0x630
#define MSR_PC9_RES 0x631
#define MSR_PC10_RES 0x632
diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
index 3041f1cd..e0e5af78 100644
--- a/tests/kms_content_protection.c
+++ b/tests/kms_content_protection.c
@@ -24,7 +24,9 @@
#include <poll.h>
#include <fcntl.h>
+#ifdef __linux__
#include <sys/epoll.h>
+#endif
#include <sys/stat.h>
#include <libudev.h>
#include "igt.h"
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 0567edea..1127e418 100755
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -45,6 +45,10 @@
#include "i915/gem_create.h"
#include "igt_stats.h"
+#ifdef __FreeBSD__
+#include <sys/consio.h>
+#endif
+
#define TEST_DPMS (1 << 0)
#define TEST_PAN (1 << 3)
diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
index 77521108..cd980c6a 100644
--- a/tests/kms_sysfs_edid_timing.c
+++ b/tests/kms_sysfs_edid_timing.c
@@ -26,6 +26,10 @@
#include <fcntl.h>
#include <sys/stat.h>
+#ifdef __FreeBSD__
+#include <limits.h>
+#endif
+
#define THRESHOLD_PER_CONNECTOR 150
#define THRESHOLD_PER_CONNECTOR_MEAN 140
#define THRESHOLD_ALL_CONNECTORS_MEAN 100
diff --git a/tests/tools_test.c b/tests/tools_test.c
index 237f0433..89a19d11 100644
--- a/tests/tools_test.c
+++ b/tests/tools_test.c
@@ -28,7 +28,11 @@
#include <fcntl.h>
#include <libgen.h>
#include <unistd.h>
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <limits.h>
+#endif
#define TOOLS "../tools/"
diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c
index ad5ee6a6..3e53c6d9 100644
--- a/tools/intel_gvtg_test.c
+++ b/tools/intel_gvtg_test.c
@@ -55,6 +55,10 @@
#include <limits.h>
#include <dirent.h>
+#ifdef __FreeBSD__
+#include <sys/wait.h>
+#endif
+
#define RANDOM(x) (rand() % x)
--
2.37.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility
2022-09-11 0:25 Jake Freeland
2022-09-13 9:53 ` Petri Latvala
@ 2022-09-14 20:16 ` Kamil Konieczny
2022-09-18 22:07 ` Jake Freeland
1 sibling, 1 reply; 20+ messages in thread
From: Kamil Konieczny @ 2022-09-14 20:16 UTC (permalink / raw)
To: igt-dev; +Cc: Petri Latvala, Jake Freeland
Hi Jake,
On 2022-09-10 at 19:25:30 -0500, Jake Freeland wrote:
> Signed-off-by: Jake Freeland <jfree@freebsd.org>
> ---
> benchmarks/gem_exec_tracer.c | 4 +
> benchmarks/gem_syslatency.c | 6 ++
> include/linux-uapi/sync_file.h | 5 ++
> lib/i915/gem_mman.c | 4 +-
> lib/i915/intel_memory_region.c | 4 +
> lib/i915/perf.c | 2 +
> lib/igt_audio.c | 4 +
> lib/igt_aux.c | 6 +-
> lib/igt_aux.h | 6 +-
> lib/igt_core.c | 8 +-
> lib/igt_core.h | 5 ++
> lib/igt_debugfs.c | 2 +
> lib/igt_device.c | 2 +
> lib/igt_device_scan.c | 4 +
> lib/igt_eld.c | 4 +
> lib/igt_frame.c | 4 +
> lib/igt_freebsd.h | 123 ++++++++++++++++++++++++++++
> lib/igt_kmod.h | 2 +
> lib/igt_kms.c | 4 +
> lib/igt_os.c | 19 +++++
> lib/igt_perf.c | 2 +
> lib/igt_perf.h | 4 +
> lib/igt_pm.c | 2 +
> lib/igt_sysfs.c | 2 +
> lib/igt_vgem.c | 2 +-
> lib/tests/igt_exit_handler.c | 4 +
> lib/tests/igt_fork.c | 2 +-
> lib/tests/igt_tests_common.h | 9 ++
> runner/executor.c | 6 ++
> runner/job_list.c | 5 ++
> tests/i915/gem_close_race.c | 2 +
> tests/i915/gem_mmap_gtt.c | 24 +++---
> tests/i915/gem_mmap_offset.c | 16 ++--
> tests/i915/i915_module_load.c | 2 +
> tests/i915/i915_pm_backlight.c | 4 +
> tests/i915/i915_pm_rpm.c | 8 ++
> tests/kms_content_protection.c | 2 +
> tests/kms_flip.c | 4 +
> tests/kms_sysfs_edid_timing.c | 4 +
> tests/tools_test.c | 10 ++-
> tools/i915-perf/i915_perf_control.c | 2 +-
> tools/intel_gvtg_test.c | 4 +
> 42 files changed, 301 insertions(+), 37 deletions(-)
> create mode 100644 lib/igt_freebsd.h
>
> diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
> index e6973991..7e86473e 100644
> --- a/benchmarks/gem_exec_tracer.c
> +++ b/benchmarks/gem_exec_tracer.c
> @@ -41,6 +41,10 @@
> #include "intel_aub.h"
> #include "intel_chipset.h"
>
> +#ifdef __FreeBSD__
> +#include "igt_freebsd.h"
> +#endif
> +
Is it possible to keep changes as minimal as possible ?
E.g. change as much as you can in libs and/or includes, so you
can do not touch tests or benchmarks ?
> static int (*libc_close)(int fd);
> static int (*libc_ioctl)(int fd, unsigned long request, void *argp);
>
> diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
> index 035ee934..dafc6ac0 100644
> --- a/benchmarks/gem_syslatency.c
> +++ b/benchmarks/gem_syslatency.c
> @@ -42,12 +42,18 @@
> #include <limits.h>
> #include "drm.h"
>
> +#ifdef __linux__
> #include <linux/unistd.h>
> +#elif defined(__FreeBSD__)
> +#include "igt_freebsd.h"
> +#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/include/linux-uapi/sync_file.h b/include/linux-uapi/sync_file.h
> index b4f2db00..270c1cbc 100644
> --- a/include/linux-uapi/sync_file.h
> +++ b/include/linux-uapi/sync_file.h
> @@ -12,8 +12,13 @@
> #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 "igt_freebsd.h"
> +#endif
>
> /**
> * struct sync_merge_data - data passed to merge ioctl
> diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
> index aa9ac6f3..0b41ba70 100644
> --- a/lib/i915/gem_mman.c
> +++ b/lib/i915/gem_mman.c
> @@ -118,7 +118,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);
Please move all mmap changes to separate patch, it will improve
readeability.
> if (ptr == MAP_FAILED)
> ptr = NULL;
> else
> @@ -331,7 +331,7 @@ void *__gem_mmap_offset(int fd, uint32_t handle, uint64_t offset, uint64_t size,
> if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_OFFSET, &arg))
> return NULL;
>
> - ptr = mmap64(0, size, prot, MAP_SHARED, fd, arg.offset + offset);
> + ptr = mmap(0, size, prot, MAP_SHARED, fd, arg.offset + offset);
>
> if (ptr == MAP_FAILED)
> ptr = NULL;
> diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
> index 93a18982..ca7f9140 100644
> --- a/lib/i915/intel_memory_region.c
> +++ b/lib/i915/intel_memory_region.c
> @@ -21,7 +21,11 @@
> * IN THE SOFTWARE.
> */
>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#elif defined(__FreeBSD__)
> +#include <limits.h>
> +#endif
> #include <signal.h>
> #include <sys/ioctl.h>
> #include <sys/time.h>
> diff --git a/lib/i915/perf.c b/lib/i915/perf.c
> index d88835ff..beda6b8a 100644
> --- a/lib/i915/perf.c
> +++ b/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/lib/igt_audio.c b/lib/igt_audio.c
> index e0b1bafe..201a39c6 100644
> --- a/lib/igt_audio.c
> +++ b/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/lib/igt_aux.c b/lib/igt_aux.c
> index edb53425..ba2d52e8 100644
> --- a/lib/igt_aux.c
> +++ b/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"
> @@ -323,10 +325,10 @@ void igt_fork_signal_helper(void)
> * and we send the signal at exactly the wrong time).
> */
> signal(SIGCONT, sig_handler);
> - setpgrp(); /* define a new process group for the tests */
> + setpgid(0, 0); /* define a new process group for the tests */
>
> igt_fork_helper(&signal_helper) {
> - setpgrp(); /* Escape from the test process group */
> + setpgid(0, 0); /* Escape from the test process group */
>
> /* Pass along the test process group identifier,
> * negative pid => send signal to everyone in the group.
> diff --git a/lib/igt_aux.h b/lib/igt_aux.h
> index c8d487b6..912f36c1 100644
> --- a/lib/igt_aux.h
> +++ b/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/lib/igt_core.c b/lib/igt_core.c
> index e7425326..17d5e013 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -43,9 +43,7 @@
> #include <unistd.h>
> #include <sys/wait.h>
> #include <sys/types.h>
> -#ifdef __linux__
> #include <sys/syscall.h>
> -#endif
> #include <pthread.h>
> #include <sys/utsname.h>
> #include <termios.h>
> @@ -786,6 +784,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
>
> static void oom_adjust_for_doom(void)
> {
> +#ifdef __linux__
> int fd;
> const char always_kill[] = "1000";
>
> @@ -793,7 +792,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
> }
>
> /**
> @@ -2224,6 +2223,9 @@ bool __igt_fork_helper(struct igt_helper_process *proc)
> case 0:
> reset_helper_process_list();
> oom_adjust_for_doom();
> +#ifdef __FreeBSD__
> + raise(SIGTERM);
> +#endif
>
> return true;
> default:
> diff --git a/lib/igt_core.h b/lib/igt_core.h
> index aa98e8ed..295bb5d9 100644
> --- a/lib/igt_core.h
> +++ b/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,9 @@
> #define IGT_LOG_DOMAIN (NULL)
> #endif
>
> +#ifdef __FreeBSD__
> +#include "igt_freebsd.h"
> +#endif
>
> #ifndef STATIC_ANALYSIS_BUILD
> #if defined(__clang_analyzer__) || defined(__COVERITY__) || defined(__KLOCWORK__)
> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> index a56688a5..fa1e3b69 100644
> --- a/lib/igt_debugfs.c
> +++ b/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>
> diff --git a/lib/igt_device.c b/lib/igt_device.c
> index fddfba72..49b77122 100644
> --- a/lib/igt_device.c
> +++ b/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/lib/igt_device_scan.c b/lib/igt_device_scan.c
> index eb6b45b8..6a921d52 100644
> --- a/lib/igt_device_scan.c
> +++ b/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/lib/igt_eld.c b/lib/igt_eld.c
> index ef6625df..e05ad6de 100644
> --- a/lib/igt_eld.c
> +++ b/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/lib/igt_frame.c b/lib/igt_frame.c
> index 45523a79..ab74e678 100644
> --- a/lib/igt_frame.c
> +++ b/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/lib/igt_freebsd.h b/lib/igt_freebsd.h
> new file mode 100644
> index 00000000..ea2603e4
> --- /dev/null
> +++ b/lib/igt_freebsd.h
> @@ -0,0 +1,123 @@
> +/*
> + * Copyright © 2022 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.
Please use SPDX licence.
> + *
> + * Authors:
> + * Jake Freeland <jfree@freebsd.org>
> + *
> + */
> +
> +#if !defined(IGT_FREEBSD_H) && defined(__FreeBSD__)
> +#define IGT_FREEBSD_H
> +
> +#include <sys/errno.h>
> +#include <sys/mman.h>
> +#include <sys/mount.h>
> +#include <sys/sched.h>
> +#include <sys/types.h>
> +#include <sys/watchdog.h>
> +
> +#include <pthread.h>
> +#include <setjmp.h>
> +#include <signal.h>
> +#include <unistd.h>
> +
> +/*
> + * Proper substitutions:
> + * The following macros replace Linux-specific functions
> + * and macros with their FreeBSD equivalents.
> + */
> +
> +#define __s32 int32_t
> +#define __u32 uint32_t
> +#define __u64 uint64_t
> +
> +#define sighandler_t sig_t
> +#define ino64_t ino_t
> +
> +#define jmp_buf sigjmp_buf
> +
> +#define PTRACE_TRACEME PT_TRACE_ME
> +#define PTRACE_ATTACH PT_ATTACH
> +#define PTRACE_PEEKDATA PT_READ_D
> +#define PTRACE_POKEDATA PT_WRITE_D
> +#define PTRACE_DETACH PT_DETACH
> +
> +#define I2C_RDWR I2CRDWR
> +#define I2C_M_RD IIC_M_RD
> +#define i2c_msg iic_msg
> +#define i2c_rdwr_ioctl_data iic_rdwr_data
> +
> +#define _IOC_TYPE(nr) (((nr) >> 8) & 255)
> +
> +#define SYS_getdents64 SYS_freebsd11_getdents
> +
> +#define mount(src, dest, fstype, flags, data) \
> + mount(fstype, dest, flags, data)
> +
> +/*
> + * Improper substitutions:
> + * The following macros are temporary replacements for functions
> + * and macros that exist on Linux and do not exist on FreeBSD.
> + */
> +
> +#define ETIME ETIMEDOUT
> +
> +#define MAP_POPULATE MAP_PREFAULT_READ
> +
> +#define MADV_HUGEPAGE MADV_SEQUENTIAL
> +#define MADV_DONTFORK MADV_NOSYNC
> +
> +#define WDIOC_KEEPALIVE WDIOCPATPAT
> +
> +#define SCHED_RESET_ON_FORK 0
> +#define SCHED_IDLE SCHED_OTHER
> +
> +#define gettid() getpid()
> +
> +#define pthread_sigqueue(pid, signo, value) \
> + sigqueue(pid, signo, value)
> +
> +#define signalfd(fd, mask, flags) -ENOSYS
> +#define timerfd_create(c, f) -ENOSYS
> +#define timerfd_settime(fd, f, n, o) -ENOSYS
> +
> +/*
> + * Macro conflict resolution.
> + */
> +
> +#undef ALIGN
> +#undef PAGE_SIZE
> +
> +struct signalfd_siginfo {
> + uint32_t ssi_signo;
> + uint32_t ssi_pid;
> +};
> +
> +struct kmod_module {
> + size_t size;
> +};
> +
> +typedef struct {
> + char state;
> +} proc_t;
> +
> +#endif /* IGT_FREEBSD_H */
> diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
> index f98dd29f..6596092b 100644
> --- a/lib/igt_kmod.h
> +++ b/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/lib/igt_kms.c b/lib/igt_kms.c
> index 1ba3bd2a..f0208c10 100644
> --- a/lib/igt_kms.c
> +++ b/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/lib/igt_os.c b/lib/igt_os.c
> index bdd5d933..ae426e3a 100644
> --- a/lib/igt_os.c
> +++ b/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 */
-------------------------------- ^
You do not need to repeat it here.
> + 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 */
-------------------------------- ^
Same here.
Regards,
Kamil
> + 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/lib/igt_perf.c b/lib/igt_perf.c
> index b743859f..11c91c5f 100644
> --- a/lib/igt_perf.c
> +++ b/lib/igt_perf.c
> @@ -4,8 +4,10 @@
> #include <stdlib.h>
> #include <string.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <sys/sysinfo.h>
> #include <sys/sysmacros.h>
> +#endif
> #include <time.h>
> #include <unistd.h>
>
> diff --git a/lib/igt_perf.h b/lib/igt_perf.h
> index a8328c70..0cd91386 100644
> --- a/lib/igt_perf.h
> +++ b/lib/igt_perf.h
> @@ -27,10 +27,13 @@
>
> #include <stdint.h>
>
> +#ifdef __linux__
> #include <linux/perf_event.h>
> +#endif
>
> #include "igt_gt.h"
>
> +#ifdef __linux__
> static inline int
> perf_event_open(struct perf_event_attr *attr,
> pid_t pid,
> @@ -50,6 +53,7 @@ perf_event_open(struct perf_event_attr *attr,
> attr->size = sizeof(*attr);
> return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);
> }
> +#endif /* __linux__ */
>
> uint64_t igt_perf_type_id(const char *device);
> int igt_perf_open(uint64_t type, uint64_t config);
> diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> index 99251b40..a6036e03 100644
> --- a/lib/igt_pm.c
> +++ b/lib/igt_pm.c
> @@ -33,7 +33,9 @@
> #include <string.h>
> #include <unistd.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <sys/sysmacros.h>
> +#endif
> #include <sys/types.h>
> #include <dirent.h>
>
> diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
> index 9c307694..a913be4c 100644
> --- a/lib/igt_sysfs.c
> +++ b/lib/igt_sysfs.c
> @@ -24,7 +24,9 @@
>
> #include <inttypes.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <sys/sysmacros.h>
> +#endif
> #include <sys/mount.h>
> #include <errno.h>
> #include <stdarg.h>
> diff --git a/lib/igt_vgem.c b/lib/igt_vgem.c
> index 7f933b23..468383c7 100644
> --- a/lib/igt_vgem.c
> +++ b/lib/igt_vgem.c
> @@ -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;
>
> diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
> index 892a7f14..d2381944 100644
> --- a/lib/tests/igt_exit_handler.c
> +++ b/lib/tests/igt_exit_handler.c
> @@ -125,5 +125,9 @@ int main(int argc, char **argv)
> internal_assert_wexited(status, IGT_EXIT_SKIP);
>
> status = testfunc(SIG);
> +#ifdef __linux__
> internal_assert_wsignaled(status, SIGTERM);
> +#elif defined(__FreeBSD__)
> + internal_assert(status == 0);
> +#endif
> }
> diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
> index d19d0945..c7193b06 100644
> --- a/lib/tests/igt_fork.c
> +++ b/lib/tests/igt_fork.c
> @@ -109,7 +109,7 @@ __noreturn static void igt_fork_timeout_leak(void)
> __noreturn static void subtest_leak(void)
> {
> pid_t *children =
> - mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
> + mmap(0, 4096, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANON, -1, 0);
> const int num_children = 4096 / sizeof(*children);
>
> igt_subtest_init(fake_argc, fake_argv);
> diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
> index 058f6265..e8183897 100644
> --- a/lib/tests/igt_tests_common.h
> +++ b/lib/tests/igt_tests_common.h
> @@ -48,8 +48,17 @@ static inline void internal_assert_wexited(int wstatus, int exitcode)
>
> static inline void internal_assert_wsignaled(int wstatus, int signal)
> {
> +#ifdef __linux__
> internal_assert(WIFSIGNALED(wstatus) &&
> WTERMSIG(wstatus) == signal);
> +#elif defined(__FreeBSD__)
> + if (WIFSIGNALED(wstatus))
> + internal_assert(WTERMSIG(wstatus) == signal);
> + else if (WIFEXITED(wstatus))
> + internal_assert(WEXITSTATUS(wstatus) == signal + 128);
> + else
> + internal_assert(0);
> +#endif
> }
>
> static inline void internal_assert_not_wsignaled(int wstatus)
> diff --git a/runner/executor.c b/runner/executor.c
> index 964d0063..c54072cf 100644
> --- a/runner/executor.c
> +++ b/runner/executor.c
> @@ -2,7 +2,9 @@
> #include <errno.h>
> #include <fcntl.h>
> #include <glib.h>
> +#ifdef __linux__
> #include <linux/watchdog.h>
> +#endif
> #if HAVE_OPING
> #include <oping.h>
> #endif
> @@ -33,6 +35,10 @@
> #define KMSG_HEADER "[IGT] "
> #define KMSG_WARN 4
>
> +#ifdef __FreeBSD__
> +#include <sys/watchdog.h>
> +#endif
> +
> static struct {
> int *fds;
> size_t num_dogs;
> diff --git a/runner/job_list.c b/runner/job_list.c
> index 520a98da..6bfa7162 100644
> --- a/runner/job_list.c
> +++ b/runner/job_list.c
> @@ -1,7 +1,12 @@
> #include <ctype.h>
> #include <errno.h>
> #include <fcntl.h>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#elif defined(__FreeBSD__)
> +#include <sys/wait.h>
> +#include <limits.h>
> +#endif
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
> index 938fde8f..42fe1657 100644
> --- a/tests/i915/gem_close_race.c
> +++ b/tests/i915/gem_close_race.c
> @@ -61,7 +61,9 @@ static bool has_softpin;
> static uint64_t exec_addr;
> static uint64_t data_addr;
>
> +#ifdef __linux__
> #define sigev_notify_thread_id _sigev_un._tid
> +#endif
>
> static void selfcopy(int fd, uint32_t ctx, uint32_t handle, int loops)
> {
> diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
> index e39b9047..683eaf16 100644
> --- a/tests/i915/gem_mmap_gtt.c
> +++ b/tests/i915/gem_mmap_gtt.c
> @@ -113,11 +113,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);
>
> @@ -128,7 +128,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));
> }
>
> @@ -159,11 +159,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);
>
> @@ -384,13 +384,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);
> }
>
> @@ -400,7 +400,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) {
> @@ -418,7 +418,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) {
> @@ -444,7 +444,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) {
> @@ -469,7 +469,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) {
> @@ -566,7 +566,7 @@ test_ptrace(int fd)
> for (int i = 0; i < sz / sizeof(long); i++) {
> long ret;
>
> - ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i);
> + ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i, NULL);
> igt_assert_eq_u64(ret, CC);
> cpy[i] = ret;
>
> diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
> index 5e6b19eb..0933ed94 100644
> --- a/tests/i915/gem_mmap_offset.c
> +++ b/tests/i915/gem_mmap_offset.c
> @@ -66,7 +66,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
> @@ -214,12 +214,12 @@ 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);
>
> @@ -237,13 +237,13 @@ static void 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);
> }
> }
> @@ -370,7 +370,7 @@ static void test_ptrace(int i915)
> for (int i = 0; i < SZ / sizeof(long); i++) {
> long ret;
>
> - ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i);
> + ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i, NULL);
> igt_assert_eq_u64(ret, CC);
> cpy[i] = ret;
>
> @@ -401,7 +401,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) {
> @@ -420,7 +420,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) {
> diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c
> index 4c72157c..9bec4c18 100644
> --- a/tests/i915/i915_module_load.c
> +++ b/tests/i915/i915_module_load.c
> @@ -23,7 +23,9 @@
> #include "igt.h"
> #include <dirent.h>
> #include <sys/utsname.h>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#endif
> #include <signal.h>
> #include <libgen.h>
> #include <signal.h>
> diff --git a/tests/i915/i915_pm_backlight.c b/tests/i915/i915_pm_backlight.c
> index cafae7f7..c520cf20 100644
> --- a/tests/i915/i915_pm_backlight.c
> +++ b/tests/i915/i915_pm_backlight.c
> @@ -46,6 +46,10 @@ struct context {
> #define FADESTEPS 10
> #define FADESPEED 100 /* milliseconds between steps */
>
> +#ifdef __FreeBSD__
> +#include <libgen.h>
> +#endif
> +
> IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
>
> static int backlight_read(int *result, const char *fname)
> diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
> index e95875dc..761e76f9 100644
> --- a/tests/i915/i915_pm_rpm.c
> +++ b/tests/i915/i915_pm_rpm.c
> @@ -40,8 +40,10 @@
> #include <sys/mman.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <linux/i2c.h>
> #include <linux/i2c-dev.h>
> +#endif
>
> #include <drm.h>
>
> @@ -54,6 +56,12 @@
> #include "igt_device.h"
> #include "igt_edid.h"
>
> +#ifdef __FreeBSD__
> +#include <limits.h>
> +#include <dev/iicbus/iic.h>
> +#define addr slave
> +#endif
> +
> #define MSR_PC8_RES 0x630
> #define MSR_PC9_RES 0x631
> #define MSR_PC10_RES 0x632
> diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
> index 3041f1cd..e0e5af78 100644
> --- a/tests/kms_content_protection.c
> +++ b/tests/kms_content_protection.c
> @@ -24,7 +24,9 @@
>
> #include <poll.h>
> #include <fcntl.h>
> +#ifdef __linux__
> #include <sys/epoll.h>
> +#endif
> #include <sys/stat.h>
> #include <libudev.h>
> #include "igt.h"
> diff --git a/tests/kms_flip.c b/tests/kms_flip.c
> index 0567edea..1127e418 100755
> --- a/tests/kms_flip.c
> +++ b/tests/kms_flip.c
> @@ -45,6 +45,10 @@
> #include "i915/gem_create.h"
> #include "igt_stats.h"
>
> +#ifdef __FreeBSD__
> +#include <sys/consio.h>
> +#endif
> +
> #define TEST_DPMS (1 << 0)
>
> #define TEST_PAN (1 << 3)
> diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
> index 77521108..cd980c6a 100644
> --- a/tests/kms_sysfs_edid_timing.c
> +++ b/tests/kms_sysfs_edid_timing.c
> @@ -26,6 +26,10 @@
> #include <fcntl.h>
> #include <sys/stat.h>
>
> +#ifdef __FreeBSD__
> +#include <limits.h>
> +#endif
> +
> #define THRESHOLD_PER_CONNECTOR 150
> #define THRESHOLD_PER_CONNECTOR_MEAN 140
> #define THRESHOLD_ALL_CONNECTORS_MEAN 100
> diff --git a/tests/tools_test.c b/tests/tools_test.c
> index 237f0433..d0684d57 100644
> --- a/tests/tools_test.c
> +++ b/tests/tools_test.c
> @@ -28,7 +28,11 @@
> #include <fcntl.h>
> #include <libgen.h>
> #include <unistd.h>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#elif defined(__FreeBSD__)
> +#include <limits.h>
> +#endif
>
> #define TOOLS "../tools/"
>
> @@ -65,7 +69,7 @@ static bool chdir_to_tools_dir(void)
> char path[PATH_MAX];
> char *cwd;
>
> - cwd = get_current_dir_name();
> + cwd = getcwd(NULL, 0);
> igt_info("Current working directory: %s\n", cwd);
> free(cwd);
>
> @@ -83,7 +87,7 @@ static bool chdir_to_tools_dir(void)
> chdir(dirname(path));
> }
>
> - cwd = get_current_dir_name();
> + cwd = getcwd(NULL, 0);
> igt_info("Current working directory: %s\n", cwd);
> free(cwd);
>
> @@ -99,7 +103,7 @@ igt_main
>
> igt_require_f(chdir_to_tools_dir(),
> "Unable to determine the tools directory, expecting them in $cwd/" TOOLS " or $path/" TOOLS "\n");
> - path = get_current_dir_name();
> + path = getcwd(NULL, 0);
> igt_info("Using tools from %s\n", path);
> free(path);
> }
> diff --git a/tools/i915-perf/i915_perf_control.c b/tools/i915-perf/i915_perf_control.c
> index be5996c0..f7db2f5c 100644
> --- a/tools/i915-perf/i915_perf_control.c
> +++ b/tools/i915-perf/i915_perf_control.c
> @@ -102,7 +102,7 @@ main(int argc, char *argv[])
>
> fwrite(data, total_len, 1, command_fifo_file);
> } else {
> - char *cwd = get_current_dir_name();
> + char *cwd = getcwd(NULL, 0);
> uint32_t path_len = strlen(cwd) + 1 + strlen(dump_file) + 1;
> uint32_t total_len = sizeof(struct recorder_command_base) + path_len;
> struct {
> diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c
> index ad5ee6a6..3e53c6d9 100644
> --- a/tools/intel_gvtg_test.c
> +++ b/tools/intel_gvtg_test.c
> @@ -55,6 +55,10 @@
> #include <limits.h>
> #include <dirent.h>
>
> +#ifdef __FreeBSD__
> +#include <sys/wait.h>
> +#endif
> +
> #define RANDOM(x) (rand() % x)
>
>
> --
> 2.37.3
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility
2022-09-11 0:25 Jake Freeland
@ 2022-09-13 9:53 ` Petri Latvala
2022-09-14 20:16 ` Kamil Konieczny
1 sibling, 0 replies; 20+ messages in thread
From: Petri Latvala @ 2022-09-13 9:53 UTC (permalink / raw)
To: Jake Freeland; +Cc: igt-dev, Jake Freeland
On Sat, Sep 10, 2022 at 07:25:30PM -0500, Jake Freeland wrote:
> Signed-off-by: Jake Freeland <jfree@freebsd.org>
> ---
> benchmarks/gem_exec_tracer.c | 4 +
> benchmarks/gem_syslatency.c | 6 ++
> include/linux-uapi/sync_file.h | 5 ++
> lib/i915/gem_mman.c | 4 +-
> lib/i915/intel_memory_region.c | 4 +
> lib/i915/perf.c | 2 +
> lib/igt_audio.c | 4 +
> lib/igt_aux.c | 6 +-
> lib/igt_aux.h | 6 +-
> lib/igt_core.c | 8 +-
> lib/igt_core.h | 5 ++
> lib/igt_debugfs.c | 2 +
> lib/igt_device.c | 2 +
> lib/igt_device_scan.c | 4 +
> lib/igt_eld.c | 4 +
> lib/igt_frame.c | 4 +
> lib/igt_freebsd.h | 123 ++++++++++++++++++++++++++++
> lib/igt_kmod.h | 2 +
> lib/igt_kms.c | 4 +
> lib/igt_os.c | 19 +++++
> lib/igt_perf.c | 2 +
> lib/igt_perf.h | 4 +
> lib/igt_pm.c | 2 +
> lib/igt_sysfs.c | 2 +
> lib/igt_vgem.c | 2 +-
> lib/tests/igt_exit_handler.c | 4 +
> lib/tests/igt_fork.c | 2 +-
> lib/tests/igt_tests_common.h | 9 ++
> runner/executor.c | 6 ++
> runner/job_list.c | 5 ++
> tests/i915/gem_close_race.c | 2 +
> tests/i915/gem_mmap_gtt.c | 24 +++---
> tests/i915/gem_mmap_offset.c | 16 ++--
> tests/i915/i915_module_load.c | 2 +
> tests/i915/i915_pm_backlight.c | 4 +
> tests/i915/i915_pm_rpm.c | 8 ++
> tests/kms_content_protection.c | 2 +
> tests/kms_flip.c | 4 +
> tests/kms_sysfs_edid_timing.c | 4 +
> tests/tools_test.c | 10 ++-
> tools/i915-perf/i915_perf_control.c | 2 +-
> tools/intel_gvtg_test.c | 4 +
> 42 files changed, 301 insertions(+), 37 deletions(-)
> create mode 100644 lib/igt_freebsd.h
>
> diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
> index e6973991..7e86473e 100644
> --- a/benchmarks/gem_exec_tracer.c
> +++ b/benchmarks/gem_exec_tracer.c
> @@ -41,6 +41,10 @@
> #include "intel_aub.h"
> #include "intel_chipset.h"
>
> +#ifdef __FreeBSD__
> +#include "igt_freebsd.h"
> +#endif
> +
> static int (*libc_close)(int fd);
> static int (*libc_ioctl)(int fd, unsigned long request, void *argp);
>
> diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
> index 035ee934..dafc6ac0 100644
> --- a/benchmarks/gem_syslatency.c
> +++ b/benchmarks/gem_syslatency.c
> @@ -42,12 +42,18 @@
> #include <limits.h>
> #include "drm.h"
>
> +#ifdef __linux__
> #include <linux/unistd.h>
> +#elif defined(__FreeBSD__)
> +#include "igt_freebsd.h"
> +#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/include/linux-uapi/sync_file.h b/include/linux-uapi/sync_file.h
> index b4f2db00..270c1cbc 100644
> --- a/include/linux-uapi/sync_file.h
> +++ b/include/linux-uapi/sync_file.h
> @@ -12,8 +12,13 @@
> #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 "igt_freebsd.h"
> +#endif
>
> /**
> * struct sync_merge_data - data passed to merge ioctl
> diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
> index aa9ac6f3..0b41ba70 100644
> --- a/lib/i915/gem_mman.c
> +++ b/lib/i915/gem_mman.c
> @@ -118,7 +118,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
> @@ -331,7 +331,7 @@ void *__gem_mmap_offset(int fd, uint32_t handle, uint64_t offset, uint64_t size,
> if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_OFFSET, &arg))
> return NULL;
>
> - ptr = mmap64(0, size, prot, MAP_SHARED, fd, arg.offset + offset);
> + ptr = mmap(0, size, prot, MAP_SHARED, fd, arg.offset + offset);
>
> if (ptr == MAP_FAILED)
> ptr = NULL;
> diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
> index 93a18982..ca7f9140 100644
> --- a/lib/i915/intel_memory_region.c
> +++ b/lib/i915/intel_memory_region.c
> @@ -21,7 +21,11 @@
> * IN THE SOFTWARE.
> */
>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#elif defined(__FreeBSD__)
> +#include <limits.h>
> +#endif
> #include <signal.h>
> #include <sys/ioctl.h>
> #include <sys/time.h>
> diff --git a/lib/i915/perf.c b/lib/i915/perf.c
> index d88835ff..beda6b8a 100644
> --- a/lib/i915/perf.c
> +++ b/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/lib/igt_audio.c b/lib/igt_audio.c
> index e0b1bafe..201a39c6 100644
> --- a/lib/igt_audio.c
> +++ b/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/lib/igt_aux.c b/lib/igt_aux.c
> index edb53425..ba2d52e8 100644
> --- a/lib/igt_aux.c
> +++ b/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"
> @@ -323,10 +325,10 @@ void igt_fork_signal_helper(void)
> * and we send the signal at exactly the wrong time).
> */
> signal(SIGCONT, sig_handler);
> - setpgrp(); /* define a new process group for the tests */
> + setpgid(0, 0); /* define a new process group for the tests */
>
> igt_fork_helper(&signal_helper) {
> - setpgrp(); /* Escape from the test process group */
> + setpgid(0, 0); /* Escape from the test process group */
>
> /* Pass along the test process group identifier,
> * negative pid => send signal to everyone in the group.
> diff --git a/lib/igt_aux.h b/lib/igt_aux.h
> index c8d487b6..912f36c1 100644
> --- a/lib/igt_aux.h
> +++ b/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/lib/igt_core.c b/lib/igt_core.c
> index e7425326..17d5e013 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -43,9 +43,7 @@
> #include <unistd.h>
> #include <sys/wait.h>
> #include <sys/types.h>
> -#ifdef __linux__
> #include <sys/syscall.h>
> -#endif
> #include <pthread.h>
> #include <sys/utsname.h>
> #include <termios.h>
> @@ -786,6 +784,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
>
> static void oom_adjust_for_doom(void)
> {
> +#ifdef __linux__
> int fd;
> const char always_kill[] = "1000";
>
> @@ -793,7 +792,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
> }
>
> /**
> @@ -2224,6 +2223,9 @@ bool __igt_fork_helper(struct igt_helper_process *proc)
> case 0:
> reset_helper_process_list();
> oom_adjust_for_doom();
> +#ifdef __FreeBSD__
> + raise(SIGTERM);
> +#endif
>
> return true;
> default:
> diff --git a/lib/igt_core.h b/lib/igt_core.h
> index aa98e8ed..295bb5d9 100644
> --- a/lib/igt_core.h
> +++ b/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,9 @@
> #define IGT_LOG_DOMAIN (NULL)
> #endif
>
> +#ifdef __FreeBSD__
> +#include "igt_freebsd.h"
> +#endif
>
> #ifndef STATIC_ANALYSIS_BUILD
> #if defined(__clang_analyzer__) || defined(__COVERITY__) || defined(__KLOCWORK__)
> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> index a56688a5..fa1e3b69 100644
> --- a/lib/igt_debugfs.c
> +++ b/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>
> diff --git a/lib/igt_device.c b/lib/igt_device.c
> index fddfba72..49b77122 100644
> --- a/lib/igt_device.c
> +++ b/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/lib/igt_device_scan.c b/lib/igt_device_scan.c
> index eb6b45b8..6a921d52 100644
> --- a/lib/igt_device_scan.c
> +++ b/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/lib/igt_eld.c b/lib/igt_eld.c
> index ef6625df..e05ad6de 100644
> --- a/lib/igt_eld.c
> +++ b/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/lib/igt_frame.c b/lib/igt_frame.c
> index 45523a79..ab74e678 100644
> --- a/lib/igt_frame.c
> +++ b/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/lib/igt_freebsd.h b/lib/igt_freebsd.h
> new file mode 100644
> index 00000000..ea2603e4
> --- /dev/null
> +++ b/lib/igt_freebsd.h
> @@ -0,0 +1,123 @@
> +/*
> + * Copyright © 2022 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.
> + *
> + * Authors:
> + * Jake Freeland <jfree@freebsd.org>
> + *
> + */
> +
> +#if !defined(IGT_FREEBSD_H) && defined(__FreeBSD__)
> +#define IGT_FREEBSD_H
> +
> +#include <sys/errno.h>
> +#include <sys/mman.h>
> +#include <sys/mount.h>
> +#include <sys/sched.h>
> +#include <sys/types.h>
> +#include <sys/watchdog.h>
> +
> +#include <pthread.h>
> +#include <setjmp.h>
> +#include <signal.h>
> +#include <unistd.h>
> +
> +/*
> + * Proper substitutions:
> + * The following macros replace Linux-specific functions
> + * and macros with their FreeBSD equivalents.
> + */
> +
> +#define __s32 int32_t
> +#define __u32 uint32_t
> +#define __u64 uint64_t
> +
> +#define sighandler_t sig_t
> +#define ino64_t ino_t
> +
> +#define jmp_buf sigjmp_buf
> +
> +#define PTRACE_TRACEME PT_TRACE_ME
> +#define PTRACE_ATTACH PT_ATTACH
> +#define PTRACE_PEEKDATA PT_READ_D
> +#define PTRACE_POKEDATA PT_WRITE_D
> +#define PTRACE_DETACH PT_DETACH
> +
> +#define I2C_RDWR I2CRDWR
> +#define I2C_M_RD IIC_M_RD
> +#define i2c_msg iic_msg
> +#define i2c_rdwr_ioctl_data iic_rdwr_data
> +
> +#define _IOC_TYPE(nr) (((nr) >> 8) & 255)
> +
> +#define SYS_getdents64 SYS_freebsd11_getdents
> +
> +#define mount(src, dest, fstype, flags, data) \
> + mount(fstype, dest, flags, data)
> +
> +/*
> + * Improper substitutions:
> + * The following macros are temporary replacements for functions
> + * and macros that exist on Linux and do not exist on FreeBSD.
> + */
> +
> +#define ETIME ETIMEDOUT
> +
> +#define MAP_POPULATE MAP_PREFAULT_READ
> +
> +#define MADV_HUGEPAGE MADV_SEQUENTIAL
> +#define MADV_DONTFORK MADV_NOSYNC
> +
> +#define WDIOC_KEEPALIVE WDIOCPATPAT
> +
> +#define SCHED_RESET_ON_FORK 0
> +#define SCHED_IDLE SCHED_OTHER
> +
> +#define gettid() getpid()
> +
> +#define pthread_sigqueue(pid, signo, value) \
> + sigqueue(pid, signo, value)
> +
> +#define signalfd(fd, mask, flags) -ENOSYS
> +#define timerfd_create(c, f) -ENOSYS
> +#define timerfd_settime(fd, f, n, o) -ENOSYS
> +
> +/*
> + * Macro conflict resolution.
> + */
> +
> +#undef ALIGN
> +#undef PAGE_SIZE
> +
> +struct signalfd_siginfo {
> + uint32_t ssi_signo;
> + uint32_t ssi_pid;
> +};
> +
> +struct kmod_module {
> + size_t size;
> +};
> +
> +typedef struct {
> + char state;
> +} proc_t;
> +
> +#endif /* IGT_FREEBSD_H */
> diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
> index f98dd29f..6596092b 100644
> --- a/lib/igt_kmod.h
> +++ b/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/lib/igt_kms.c b/lib/igt_kms.c
> index 1ba3bd2a..f0208c10 100644
> --- a/lib/igt_kms.c
> +++ b/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/lib/igt_os.c b/lib/igt_os.c
> index bdd5d933..ae426e3a 100644
> --- a/lib/igt_os.c
> +++ b/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/lib/igt_perf.c b/lib/igt_perf.c
> index b743859f..11c91c5f 100644
> --- a/lib/igt_perf.c
> +++ b/lib/igt_perf.c
> @@ -4,8 +4,10 @@
> #include <stdlib.h>
> #include <string.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <sys/sysinfo.h>
> #include <sys/sysmacros.h>
> +#endif
> #include <time.h>
> #include <unistd.h>
>
> diff --git a/lib/igt_perf.h b/lib/igt_perf.h
> index a8328c70..0cd91386 100644
> --- a/lib/igt_perf.h
> +++ b/lib/igt_perf.h
> @@ -27,10 +27,13 @@
>
> #include <stdint.h>
>
> +#ifdef __linux__
> #include <linux/perf_event.h>
> +#endif
>
> #include "igt_gt.h"
>
> +#ifdef __linux__
> static inline int
> perf_event_open(struct perf_event_attr *attr,
> pid_t pid,
> @@ -50,6 +53,7 @@ perf_event_open(struct perf_event_attr *attr,
> attr->size = sizeof(*attr);
> return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);
> }
> +#endif /* __linux__ */
>
> uint64_t igt_perf_type_id(const char *device);
> int igt_perf_open(uint64_t type, uint64_t config);
> diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> index 99251b40..a6036e03 100644
> --- a/lib/igt_pm.c
> +++ b/lib/igt_pm.c
> @@ -33,7 +33,9 @@
> #include <string.h>
> #include <unistd.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <sys/sysmacros.h>
> +#endif
> #include <sys/types.h>
> #include <dirent.h>
>
> diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
> index 9c307694..a913be4c 100644
> --- a/lib/igt_sysfs.c
> +++ b/lib/igt_sysfs.c
> @@ -24,7 +24,9 @@
>
> #include <inttypes.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <sys/sysmacros.h>
> +#endif
> #include <sys/mount.h>
> #include <errno.h>
> #include <stdarg.h>
> diff --git a/lib/igt_vgem.c b/lib/igt_vgem.c
> index 7f933b23..468383c7 100644
> --- a/lib/igt_vgem.c
> +++ b/lib/igt_vgem.c
> @@ -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;
>
> diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
> index 892a7f14..d2381944 100644
> --- a/lib/tests/igt_exit_handler.c
> +++ b/lib/tests/igt_exit_handler.c
> @@ -125,5 +125,9 @@ int main(int argc, char **argv)
> internal_assert_wexited(status, IGT_EXIT_SKIP);
>
> status = testfunc(SIG);
> +#ifdef __linux__
> internal_assert_wsignaled(status, SIGTERM);
> +#elif defined(__FreeBSD__)
> + internal_assert(status == 0);
> +#endif
> }
> diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
> index d19d0945..c7193b06 100644
> --- a/lib/tests/igt_fork.c
> +++ b/lib/tests/igt_fork.c
> @@ -109,7 +109,7 @@ __noreturn static void igt_fork_timeout_leak(void)
> __noreturn static void subtest_leak(void)
> {
> pid_t *children =
> - mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
> + mmap(0, 4096, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANON, -1, 0);
> const int num_children = 4096 / sizeof(*children);
>
> igt_subtest_init(fake_argc, fake_argv);
> diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
> index 058f6265..e8183897 100644
> --- a/lib/tests/igt_tests_common.h
> +++ b/lib/tests/igt_tests_common.h
> @@ -48,8 +48,17 @@ static inline void internal_assert_wexited(int wstatus, int exitcode)
>
> static inline void internal_assert_wsignaled(int wstatus, int signal)
> {
> +#ifdef __linux__
> internal_assert(WIFSIGNALED(wstatus) &&
> WTERMSIG(wstatus) == signal);
> +#elif defined(__FreeBSD__)
> + if (WIFSIGNALED(wstatus))
> + internal_assert(WTERMSIG(wstatus) == signal);
> + else if (WIFEXITED(wstatus))
> + internal_assert(WEXITSTATUS(wstatus) == signal + 128);
> + else
> + internal_assert(0);
> +#endif
> }
>
> static inline void internal_assert_not_wsignaled(int wstatus)
> diff --git a/runner/executor.c b/runner/executor.c
> index 964d0063..c54072cf 100644
> --- a/runner/executor.c
> +++ b/runner/executor.c
> @@ -2,7 +2,9 @@
> #include <errno.h>
> #include <fcntl.h>
> #include <glib.h>
> +#ifdef __linux__
> #include <linux/watchdog.h>
> +#endif
> #if HAVE_OPING
> #include <oping.h>
> #endif
> @@ -33,6 +35,10 @@
> #define KMSG_HEADER "[IGT] "
> #define KMSG_WARN 4
>
> +#ifdef __FreeBSD__
> +#include <sys/watchdog.h>
> +#endif
> +
> static struct {
> int *fds;
> size_t num_dogs;
> diff --git a/runner/job_list.c b/runner/job_list.c
> index 520a98da..6bfa7162 100644
> --- a/runner/job_list.c
> +++ b/runner/job_list.c
> @@ -1,7 +1,12 @@
> #include <ctype.h>
> #include <errno.h>
> #include <fcntl.h>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#elif defined(__FreeBSD__)
> +#include <sys/wait.h>
> +#include <limits.h>
> +#endif
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
> index 938fde8f..42fe1657 100644
> --- a/tests/i915/gem_close_race.c
> +++ b/tests/i915/gem_close_race.c
> @@ -61,7 +61,9 @@ static bool has_softpin;
> static uint64_t exec_addr;
> static uint64_t data_addr;
>
> +#ifdef __linux__
> #define sigev_notify_thread_id _sigev_un._tid
> +#endif
>
> static void selfcopy(int fd, uint32_t ctx, uint32_t handle, int loops)
> {
> diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
> index e39b9047..683eaf16 100644
> --- a/tests/i915/gem_mmap_gtt.c
> +++ b/tests/i915/gem_mmap_gtt.c
> @@ -113,11 +113,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);
>
> @@ -128,7 +128,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));
> }
>
> @@ -159,11 +159,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);
>
> @@ -384,13 +384,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);
> }
>
> @@ -400,7 +400,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) {
> @@ -418,7 +418,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) {
> @@ -444,7 +444,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) {
> @@ -469,7 +469,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) {
> @@ -566,7 +566,7 @@ test_ptrace(int fd)
> for (int i = 0; i < sz / sizeof(long); i++) {
> long ret;
>
> - ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i);
> + ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i, NULL);
> igt_assert_eq_u64(ret, CC);
> cpy[i] = ret;
>
> diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
> index 5e6b19eb..0933ed94 100644
> --- a/tests/i915/gem_mmap_offset.c
> +++ b/tests/i915/gem_mmap_offset.c
> @@ -66,7 +66,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
> @@ -214,12 +214,12 @@ 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);
>
> @@ -237,13 +237,13 @@ static void 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);
> }
> }
> @@ -370,7 +370,7 @@ static void test_ptrace(int i915)
> for (int i = 0; i < SZ / sizeof(long); i++) {
> long ret;
>
> - ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i);
> + ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i, NULL);
> igt_assert_eq_u64(ret, CC);
> cpy[i] = ret;
>
> @@ -401,7 +401,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) {
> @@ -420,7 +420,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) {
> diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c
> index 4c72157c..9bec4c18 100644
> --- a/tests/i915/i915_module_load.c
> +++ b/tests/i915/i915_module_load.c
> @@ -23,7 +23,9 @@
> #include "igt.h"
> #include <dirent.h>
> #include <sys/utsname.h>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#endif
> #include <signal.h>
> #include <libgen.h>
> #include <signal.h>
> diff --git a/tests/i915/i915_pm_backlight.c b/tests/i915/i915_pm_backlight.c
> index cafae7f7..c520cf20 100644
> --- a/tests/i915/i915_pm_backlight.c
> +++ b/tests/i915/i915_pm_backlight.c
> @@ -46,6 +46,10 @@ struct context {
> #define FADESTEPS 10
> #define FADESPEED 100 /* milliseconds between steps */
>
> +#ifdef __FreeBSD__
> +#include <libgen.h>
> +#endif
> +
> IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
>
> static int backlight_read(int *result, const char *fname)
> diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
> index e95875dc..761e76f9 100644
> --- a/tests/i915/i915_pm_rpm.c
> +++ b/tests/i915/i915_pm_rpm.c
> @@ -40,8 +40,10 @@
> #include <sys/mman.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <linux/i2c.h>
> #include <linux/i2c-dev.h>
> +#endif
>
> #include <drm.h>
>
> @@ -54,6 +56,12 @@
> #include "igt_device.h"
> #include "igt_edid.h"
>
> +#ifdef __FreeBSD__
> +#include <limits.h>
> +#include <dev/iicbus/iic.h>
> +#define addr slave
> +#endif
> +
> #define MSR_PC8_RES 0x630
> #define MSR_PC9_RES 0x631
> #define MSR_PC10_RES 0x632
> diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
> index 3041f1cd..e0e5af78 100644
> --- a/tests/kms_content_protection.c
> +++ b/tests/kms_content_protection.c
> @@ -24,7 +24,9 @@
>
> #include <poll.h>
> #include <fcntl.h>
> +#ifdef __linux__
> #include <sys/epoll.h>
> +#endif
> #include <sys/stat.h>
> #include <libudev.h>
> #include "igt.h"
> diff --git a/tests/kms_flip.c b/tests/kms_flip.c
> index 0567edea..1127e418 100755
> --- a/tests/kms_flip.c
> +++ b/tests/kms_flip.c
> @@ -45,6 +45,10 @@
> #include "i915/gem_create.h"
> #include "igt_stats.h"
>
> +#ifdef __FreeBSD__
> +#include <sys/consio.h>
> +#endif
> +
> #define TEST_DPMS (1 << 0)
>
> #define TEST_PAN (1 << 3)
> diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
> index 77521108..cd980c6a 100644
> --- a/tests/kms_sysfs_edid_timing.c
> +++ b/tests/kms_sysfs_edid_timing.c
> @@ -26,6 +26,10 @@
> #include <fcntl.h>
> #include <sys/stat.h>
>
> +#ifdef __FreeBSD__
> +#include <limits.h>
> +#endif
> +
> #define THRESHOLD_PER_CONNECTOR 150
> #define THRESHOLD_PER_CONNECTOR_MEAN 140
> #define THRESHOLD_ALL_CONNECTORS_MEAN 100
> diff --git a/tests/tools_test.c b/tests/tools_test.c
> index 237f0433..d0684d57 100644
> --- a/tests/tools_test.c
> +++ b/tests/tools_test.c
> @@ -28,7 +28,11 @@
> #include <fcntl.h>
> #include <libgen.h>
> #include <unistd.h>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#elif defined(__FreeBSD__)
> +#include <limits.h>
> +#endif
>
> #define TOOLS "../tools/"
>
> @@ -65,7 +69,7 @@ static bool chdir_to_tools_dir(void)
> char path[PATH_MAX];
> char *cwd;
>
> - cwd = get_current_dir_name();
> + cwd = getcwd(NULL, 0);
According to my man pages, making getcwd malloc a buffer itself when
NULL is passed is a glibc extension. Does it work that way for FreeBSD
too?
--
Petri Latvala
> igt_info("Current working directory: %s\n", cwd);
> free(cwd);
>
> @@ -83,7 +87,7 @@ static bool chdir_to_tools_dir(void)
> chdir(dirname(path));
> }
>
> - cwd = get_current_dir_name();
> + cwd = getcwd(NULL, 0);
> igt_info("Current working directory: %s\n", cwd);
> free(cwd);
>
> @@ -99,7 +103,7 @@ igt_main
>
> igt_require_f(chdir_to_tools_dir(),
> "Unable to determine the tools directory, expecting them in $cwd/" TOOLS " or $path/" TOOLS "\n");
> - path = get_current_dir_name();
> + path = getcwd(NULL, 0);
> igt_info("Using tools from %s\n", path);
> free(path);
> }
> diff --git a/tools/i915-perf/i915_perf_control.c b/tools/i915-perf/i915_perf_control.c
> index be5996c0..f7db2f5c 100644
> --- a/tools/i915-perf/i915_perf_control.c
> +++ b/tools/i915-perf/i915_perf_control.c
> @@ -102,7 +102,7 @@ main(int argc, char *argv[])
>
> fwrite(data, total_len, 1, command_fifo_file);
> } else {
> - char *cwd = get_current_dir_name();
> + char *cwd = getcwd(NULL, 0);
> uint32_t path_len = strlen(cwd) + 1 + strlen(dump_file) + 1;
> uint32_t total_len = sizeof(struct recorder_command_base) + path_len;
> struct {
> diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c
> index ad5ee6a6..3e53c6d9 100644
> --- a/tools/intel_gvtg_test.c
> +++ b/tools/intel_gvtg_test.c
> @@ -55,6 +55,10 @@
> #include <limits.h>
> #include <dirent.h>
>
> +#ifdef __FreeBSD__
> +#include <sys/wait.h>
> +#endif
> +
> #define RANDOM(x) (rand() % x)
>
>
> --
> 2.37.3
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility
@ 2022-09-11 0:25 Jake Freeland
2022-09-13 9:53 ` Petri Latvala
2022-09-14 20:16 ` Kamil Konieczny
0 siblings, 2 replies; 20+ messages in thread
From: Jake Freeland @ 2022-09-11 0:25 UTC (permalink / raw)
To: igt-dev; +Cc: Jake Freeland
Signed-off-by: Jake Freeland <jfree@freebsd.org>
---
benchmarks/gem_exec_tracer.c | 4 +
benchmarks/gem_syslatency.c | 6 ++
include/linux-uapi/sync_file.h | 5 ++
lib/i915/gem_mman.c | 4 +-
lib/i915/intel_memory_region.c | 4 +
lib/i915/perf.c | 2 +
lib/igt_audio.c | 4 +
lib/igt_aux.c | 6 +-
lib/igt_aux.h | 6 +-
lib/igt_core.c | 8 +-
lib/igt_core.h | 5 ++
lib/igt_debugfs.c | 2 +
lib/igt_device.c | 2 +
lib/igt_device_scan.c | 4 +
lib/igt_eld.c | 4 +
lib/igt_frame.c | 4 +
lib/igt_freebsd.h | 123 ++++++++++++++++++++++++++++
lib/igt_kmod.h | 2 +
lib/igt_kms.c | 4 +
lib/igt_os.c | 19 +++++
lib/igt_perf.c | 2 +
lib/igt_perf.h | 4 +
lib/igt_pm.c | 2 +
lib/igt_sysfs.c | 2 +
lib/igt_vgem.c | 2 +-
lib/tests/igt_exit_handler.c | 4 +
lib/tests/igt_fork.c | 2 +-
lib/tests/igt_tests_common.h | 9 ++
runner/executor.c | 6 ++
runner/job_list.c | 5 ++
tests/i915/gem_close_race.c | 2 +
tests/i915/gem_mmap_gtt.c | 24 +++---
tests/i915/gem_mmap_offset.c | 16 ++--
tests/i915/i915_module_load.c | 2 +
tests/i915/i915_pm_backlight.c | 4 +
tests/i915/i915_pm_rpm.c | 8 ++
tests/kms_content_protection.c | 2 +
tests/kms_flip.c | 4 +
tests/kms_sysfs_edid_timing.c | 4 +
tests/tools_test.c | 10 ++-
tools/i915-perf/i915_perf_control.c | 2 +-
tools/intel_gvtg_test.c | 4 +
42 files changed, 301 insertions(+), 37 deletions(-)
create mode 100644 lib/igt_freebsd.h
diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
index e6973991..7e86473e 100644
--- a/benchmarks/gem_exec_tracer.c
+++ b/benchmarks/gem_exec_tracer.c
@@ -41,6 +41,10 @@
#include "intel_aub.h"
#include "intel_chipset.h"
+#ifdef __FreeBSD__
+#include "igt_freebsd.h"
+#endif
+
static int (*libc_close)(int fd);
static int (*libc_ioctl)(int fd, unsigned long request, void *argp);
diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
index 035ee934..dafc6ac0 100644
--- a/benchmarks/gem_syslatency.c
+++ b/benchmarks/gem_syslatency.c
@@ -42,12 +42,18 @@
#include <limits.h>
#include "drm.h"
+#ifdef __linux__
#include <linux/unistd.h>
+#elif defined(__FreeBSD__)
+#include "igt_freebsd.h"
+#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/include/linux-uapi/sync_file.h b/include/linux-uapi/sync_file.h
index b4f2db00..270c1cbc 100644
--- a/include/linux-uapi/sync_file.h
+++ b/include/linux-uapi/sync_file.h
@@ -12,8 +12,13 @@
#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 "igt_freebsd.h"
+#endif
/**
* struct sync_merge_data - data passed to merge ioctl
diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
index aa9ac6f3..0b41ba70 100644
--- a/lib/i915/gem_mman.c
+++ b/lib/i915/gem_mman.c
@@ -118,7 +118,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
@@ -331,7 +331,7 @@ void *__gem_mmap_offset(int fd, uint32_t handle, uint64_t offset, uint64_t size,
if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_OFFSET, &arg))
return NULL;
- ptr = mmap64(0, size, prot, MAP_SHARED, fd, arg.offset + offset);
+ ptr = mmap(0, size, prot, MAP_SHARED, fd, arg.offset + offset);
if (ptr == MAP_FAILED)
ptr = NULL;
diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
index 93a18982..ca7f9140 100644
--- a/lib/i915/intel_memory_region.c
+++ b/lib/i915/intel_memory_region.c
@@ -21,7 +21,11 @@
* IN THE SOFTWARE.
*/
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <limits.h>
+#endif
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/time.h>
diff --git a/lib/i915/perf.c b/lib/i915/perf.c
index d88835ff..beda6b8a 100644
--- a/lib/i915/perf.c
+++ b/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/lib/igt_audio.c b/lib/igt_audio.c
index e0b1bafe..201a39c6 100644
--- a/lib/igt_audio.c
+++ b/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/lib/igt_aux.c b/lib/igt_aux.c
index edb53425..ba2d52e8 100644
--- a/lib/igt_aux.c
+++ b/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"
@@ -323,10 +325,10 @@ void igt_fork_signal_helper(void)
* and we send the signal at exactly the wrong time).
*/
signal(SIGCONT, sig_handler);
- setpgrp(); /* define a new process group for the tests */
+ setpgid(0, 0); /* define a new process group for the tests */
igt_fork_helper(&signal_helper) {
- setpgrp(); /* Escape from the test process group */
+ setpgid(0, 0); /* Escape from the test process group */
/* Pass along the test process group identifier,
* negative pid => send signal to everyone in the group.
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index c8d487b6..912f36c1 100644
--- a/lib/igt_aux.h
+++ b/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/lib/igt_core.c b/lib/igt_core.c
index e7425326..17d5e013 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -43,9 +43,7 @@
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
-#ifdef __linux__
#include <sys/syscall.h>
-#endif
#include <pthread.h>
#include <sys/utsname.h>
#include <termios.h>
@@ -786,6 +784,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
static void oom_adjust_for_doom(void)
{
+#ifdef __linux__
int fd;
const char always_kill[] = "1000";
@@ -793,7 +792,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
}
/**
@@ -2224,6 +2223,9 @@ bool __igt_fork_helper(struct igt_helper_process *proc)
case 0:
reset_helper_process_list();
oom_adjust_for_doom();
+#ifdef __FreeBSD__
+ raise(SIGTERM);
+#endif
return true;
default:
diff --git a/lib/igt_core.h b/lib/igt_core.h
index aa98e8ed..295bb5d9 100644
--- a/lib/igt_core.h
+++ b/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,9 @@
#define IGT_LOG_DOMAIN (NULL)
#endif
+#ifdef __FreeBSD__
+#include "igt_freebsd.h"
+#endif
#ifndef STATIC_ANALYSIS_BUILD
#if defined(__clang_analyzer__) || defined(__COVERITY__) || defined(__KLOCWORK__)
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index a56688a5..fa1e3b69 100644
--- a/lib/igt_debugfs.c
+++ b/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>
diff --git a/lib/igt_device.c b/lib/igt_device.c
index fddfba72..49b77122 100644
--- a/lib/igt_device.c
+++ b/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/lib/igt_device_scan.c b/lib/igt_device_scan.c
index eb6b45b8..6a921d52 100644
--- a/lib/igt_device_scan.c
+++ b/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/lib/igt_eld.c b/lib/igt_eld.c
index ef6625df..e05ad6de 100644
--- a/lib/igt_eld.c
+++ b/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/lib/igt_frame.c b/lib/igt_frame.c
index 45523a79..ab74e678 100644
--- a/lib/igt_frame.c
+++ b/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/lib/igt_freebsd.h b/lib/igt_freebsd.h
new file mode 100644
index 00000000..ea2603e4
--- /dev/null
+++ b/lib/igt_freebsd.h
@@ -0,0 +1,123 @@
+/*
+ * Copyright © 2022 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.
+ *
+ * Authors:
+ * Jake Freeland <jfree@freebsd.org>
+ *
+ */
+
+#if !defined(IGT_FREEBSD_H) && defined(__FreeBSD__)
+#define IGT_FREEBSD_H
+
+#include <sys/errno.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/sched.h>
+#include <sys/types.h>
+#include <sys/watchdog.h>
+
+#include <pthread.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <unistd.h>
+
+/*
+ * Proper substitutions:
+ * The following macros replace Linux-specific functions
+ * and macros with their FreeBSD equivalents.
+ */
+
+#define __s32 int32_t
+#define __u32 uint32_t
+#define __u64 uint64_t
+
+#define sighandler_t sig_t
+#define ino64_t ino_t
+
+#define jmp_buf sigjmp_buf
+
+#define PTRACE_TRACEME PT_TRACE_ME
+#define PTRACE_ATTACH PT_ATTACH
+#define PTRACE_PEEKDATA PT_READ_D
+#define PTRACE_POKEDATA PT_WRITE_D
+#define PTRACE_DETACH PT_DETACH
+
+#define I2C_RDWR I2CRDWR
+#define I2C_M_RD IIC_M_RD
+#define i2c_msg iic_msg
+#define i2c_rdwr_ioctl_data iic_rdwr_data
+
+#define _IOC_TYPE(nr) (((nr) >> 8) & 255)
+
+#define SYS_getdents64 SYS_freebsd11_getdents
+
+#define mount(src, dest, fstype, flags, data) \
+ mount(fstype, dest, flags, data)
+
+/*
+ * Improper substitutions:
+ * The following macros are temporary replacements for functions
+ * and macros that exist on Linux and do not exist on FreeBSD.
+ */
+
+#define ETIME ETIMEDOUT
+
+#define MAP_POPULATE MAP_PREFAULT_READ
+
+#define MADV_HUGEPAGE MADV_SEQUENTIAL
+#define MADV_DONTFORK MADV_NOSYNC
+
+#define WDIOC_KEEPALIVE WDIOCPATPAT
+
+#define SCHED_RESET_ON_FORK 0
+#define SCHED_IDLE SCHED_OTHER
+
+#define gettid() getpid()
+
+#define pthread_sigqueue(pid, signo, value) \
+ sigqueue(pid, signo, value)
+
+#define signalfd(fd, mask, flags) -ENOSYS
+#define timerfd_create(c, f) -ENOSYS
+#define timerfd_settime(fd, f, n, o) -ENOSYS
+
+/*
+ * Macro conflict resolution.
+ */
+
+#undef ALIGN
+#undef PAGE_SIZE
+
+struct signalfd_siginfo {
+ uint32_t ssi_signo;
+ uint32_t ssi_pid;
+};
+
+struct kmod_module {
+ size_t size;
+};
+
+typedef struct {
+ char state;
+} proc_t;
+
+#endif /* IGT_FREEBSD_H */
diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
index f98dd29f..6596092b 100644
--- a/lib/igt_kmod.h
+++ b/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/lib/igt_kms.c b/lib/igt_kms.c
index 1ba3bd2a..f0208c10 100644
--- a/lib/igt_kms.c
+++ b/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/lib/igt_os.c b/lib/igt_os.c
index bdd5d933..ae426e3a 100644
--- a/lib/igt_os.c
+++ b/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/lib/igt_perf.c b/lib/igt_perf.c
index b743859f..11c91c5f 100644
--- a/lib/igt_perf.c
+++ b/lib/igt_perf.c
@@ -4,8 +4,10 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysinfo.h>
#include <sys/sysmacros.h>
+#endif
#include <time.h>
#include <unistd.h>
diff --git a/lib/igt_perf.h b/lib/igt_perf.h
index a8328c70..0cd91386 100644
--- a/lib/igt_perf.h
+++ b/lib/igt_perf.h
@@ -27,10 +27,13 @@
#include <stdint.h>
+#ifdef __linux__
#include <linux/perf_event.h>
+#endif
#include "igt_gt.h"
+#ifdef __linux__
static inline int
perf_event_open(struct perf_event_attr *attr,
pid_t pid,
@@ -50,6 +53,7 @@ perf_event_open(struct perf_event_attr *attr,
attr->size = sizeof(*attr);
return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);
}
+#endif /* __linux__ */
uint64_t igt_perf_type_id(const char *device);
int igt_perf_open(uint64_t type, uint64_t config);
diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 99251b40..a6036e03 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,7 +33,9 @@
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysmacros.h>
+#endif
#include <sys/types.h>
#include <dirent.h>
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 9c307694..a913be4c 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -24,7 +24,9 @@
#include <inttypes.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysmacros.h>
+#endif
#include <sys/mount.h>
#include <errno.h>
#include <stdarg.h>
diff --git a/lib/igt_vgem.c b/lib/igt_vgem.c
index 7f933b23..468383c7 100644
--- a/lib/igt_vgem.c
+++ b/lib/igt_vgem.c
@@ -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;
diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
index 892a7f14..d2381944 100644
--- a/lib/tests/igt_exit_handler.c
+++ b/lib/tests/igt_exit_handler.c
@@ -125,5 +125,9 @@ int main(int argc, char **argv)
internal_assert_wexited(status, IGT_EXIT_SKIP);
status = testfunc(SIG);
+#ifdef __linux__
internal_assert_wsignaled(status, SIGTERM);
+#elif defined(__FreeBSD__)
+ internal_assert(status == 0);
+#endif
}
diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
index d19d0945..c7193b06 100644
--- a/lib/tests/igt_fork.c
+++ b/lib/tests/igt_fork.c
@@ -109,7 +109,7 @@ __noreturn static void igt_fork_timeout_leak(void)
__noreturn static void subtest_leak(void)
{
pid_t *children =
- mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+ mmap(0, 4096, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANON, -1, 0);
const int num_children = 4096 / sizeof(*children);
igt_subtest_init(fake_argc, fake_argv);
diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
index 058f6265..e8183897 100644
--- a/lib/tests/igt_tests_common.h
+++ b/lib/tests/igt_tests_common.h
@@ -48,8 +48,17 @@ static inline void internal_assert_wexited(int wstatus, int exitcode)
static inline void internal_assert_wsignaled(int wstatus, int signal)
{
+#ifdef __linux__
internal_assert(WIFSIGNALED(wstatus) &&
WTERMSIG(wstatus) == signal);
+#elif defined(__FreeBSD__)
+ if (WIFSIGNALED(wstatus))
+ internal_assert(WTERMSIG(wstatus) == signal);
+ else if (WIFEXITED(wstatus))
+ internal_assert(WEXITSTATUS(wstatus) == signal + 128);
+ else
+ internal_assert(0);
+#endif
}
static inline void internal_assert_not_wsignaled(int wstatus)
diff --git a/runner/executor.c b/runner/executor.c
index 964d0063..c54072cf 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -2,7 +2,9 @@
#include <errno.h>
#include <fcntl.h>
#include <glib.h>
+#ifdef __linux__
#include <linux/watchdog.h>
+#endif
#if HAVE_OPING
#include <oping.h>
#endif
@@ -33,6 +35,10 @@
#define KMSG_HEADER "[IGT] "
#define KMSG_WARN 4
+#ifdef __FreeBSD__
+#include <sys/watchdog.h>
+#endif
+
static struct {
int *fds;
size_t num_dogs;
diff --git a/runner/job_list.c b/runner/job_list.c
index 520a98da..6bfa7162 100644
--- a/runner/job_list.c
+++ b/runner/job_list.c
@@ -1,7 +1,12 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <sys/wait.h>
+#include <limits.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
index 938fde8f..42fe1657 100644
--- a/tests/i915/gem_close_race.c
+++ b/tests/i915/gem_close_race.c
@@ -61,7 +61,9 @@ static bool has_softpin;
static uint64_t exec_addr;
static uint64_t data_addr;
+#ifdef __linux__
#define sigev_notify_thread_id _sigev_un._tid
+#endif
static void selfcopy(int fd, uint32_t ctx, uint32_t handle, int loops)
{
diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
index e39b9047..683eaf16 100644
--- a/tests/i915/gem_mmap_gtt.c
+++ b/tests/i915/gem_mmap_gtt.c
@@ -113,11 +113,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);
@@ -128,7 +128,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));
}
@@ -159,11 +159,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);
@@ -384,13 +384,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);
}
@@ -400,7 +400,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) {
@@ -418,7 +418,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) {
@@ -444,7 +444,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) {
@@ -469,7 +469,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) {
@@ -566,7 +566,7 @@ test_ptrace(int fd)
for (int i = 0; i < sz / sizeof(long); i++) {
long ret;
- ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i);
+ ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i, NULL);
igt_assert_eq_u64(ret, CC);
cpy[i] = ret;
diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
index 5e6b19eb..0933ed94 100644
--- a/tests/i915/gem_mmap_offset.c
+++ b/tests/i915/gem_mmap_offset.c
@@ -66,7 +66,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
@@ -214,12 +214,12 @@ 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);
@@ -237,13 +237,13 @@ static void 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);
}
}
@@ -370,7 +370,7 @@ static void test_ptrace(int i915)
for (int i = 0; i < SZ / sizeof(long); i++) {
long ret;
- ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i);
+ ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i, NULL);
igt_assert_eq_u64(ret, CC);
cpy[i] = ret;
@@ -401,7 +401,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) {
@@ -420,7 +420,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) {
diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c
index 4c72157c..9bec4c18 100644
--- a/tests/i915/i915_module_load.c
+++ b/tests/i915/i915_module_load.c
@@ -23,7 +23,9 @@
#include "igt.h"
#include <dirent.h>
#include <sys/utsname.h>
+#ifdef __linux__
#include <linux/limits.h>
+#endif
#include <signal.h>
#include <libgen.h>
#include <signal.h>
diff --git a/tests/i915/i915_pm_backlight.c b/tests/i915/i915_pm_backlight.c
index cafae7f7..c520cf20 100644
--- a/tests/i915/i915_pm_backlight.c
+++ b/tests/i915/i915_pm_backlight.c
@@ -46,6 +46,10 @@ struct context {
#define FADESTEPS 10
#define FADESPEED 100 /* milliseconds between steps */
+#ifdef __FreeBSD__
+#include <libgen.h>
+#endif
+
IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
static int backlight_read(int *result, const char *fname)
diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
index e95875dc..761e76f9 100644
--- a/tests/i915/i915_pm_rpm.c
+++ b/tests/i915/i915_pm_rpm.c
@@ -40,8 +40,10 @@
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
+#endif
#include <drm.h>
@@ -54,6 +56,12 @@
#include "igt_device.h"
#include "igt_edid.h"
+#ifdef __FreeBSD__
+#include <limits.h>
+#include <dev/iicbus/iic.h>
+#define addr slave
+#endif
+
#define MSR_PC8_RES 0x630
#define MSR_PC9_RES 0x631
#define MSR_PC10_RES 0x632
diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
index 3041f1cd..e0e5af78 100644
--- a/tests/kms_content_protection.c
+++ b/tests/kms_content_protection.c
@@ -24,7 +24,9 @@
#include <poll.h>
#include <fcntl.h>
+#ifdef __linux__
#include <sys/epoll.h>
+#endif
#include <sys/stat.h>
#include <libudev.h>
#include "igt.h"
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 0567edea..1127e418 100755
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -45,6 +45,10 @@
#include "i915/gem_create.h"
#include "igt_stats.h"
+#ifdef __FreeBSD__
+#include <sys/consio.h>
+#endif
+
#define TEST_DPMS (1 << 0)
#define TEST_PAN (1 << 3)
diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
index 77521108..cd980c6a 100644
--- a/tests/kms_sysfs_edid_timing.c
+++ b/tests/kms_sysfs_edid_timing.c
@@ -26,6 +26,10 @@
#include <fcntl.h>
#include <sys/stat.h>
+#ifdef __FreeBSD__
+#include <limits.h>
+#endif
+
#define THRESHOLD_PER_CONNECTOR 150
#define THRESHOLD_PER_CONNECTOR_MEAN 140
#define THRESHOLD_ALL_CONNECTORS_MEAN 100
diff --git a/tests/tools_test.c b/tests/tools_test.c
index 237f0433..d0684d57 100644
--- a/tests/tools_test.c
+++ b/tests/tools_test.c
@@ -28,7 +28,11 @@
#include <fcntl.h>
#include <libgen.h>
#include <unistd.h>
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <limits.h>
+#endif
#define TOOLS "../tools/"
@@ -65,7 +69,7 @@ static bool chdir_to_tools_dir(void)
char path[PATH_MAX];
char *cwd;
- cwd = get_current_dir_name();
+ cwd = getcwd(NULL, 0);
igt_info("Current working directory: %s\n", cwd);
free(cwd);
@@ -83,7 +87,7 @@ static bool chdir_to_tools_dir(void)
chdir(dirname(path));
}
- cwd = get_current_dir_name();
+ cwd = getcwd(NULL, 0);
igt_info("Current working directory: %s\n", cwd);
free(cwd);
@@ -99,7 +103,7 @@ igt_main
igt_require_f(chdir_to_tools_dir(),
"Unable to determine the tools directory, expecting them in $cwd/" TOOLS " or $path/" TOOLS "\n");
- path = get_current_dir_name();
+ path = getcwd(NULL, 0);
igt_info("Using tools from %s\n", path);
free(path);
}
diff --git a/tools/i915-perf/i915_perf_control.c b/tools/i915-perf/i915_perf_control.c
index be5996c0..f7db2f5c 100644
--- a/tools/i915-perf/i915_perf_control.c
+++ b/tools/i915-perf/i915_perf_control.c
@@ -102,7 +102,7 @@ main(int argc, char *argv[])
fwrite(data, total_len, 1, command_fifo_file);
} else {
- char *cwd = get_current_dir_name();
+ char *cwd = getcwd(NULL, 0);
uint32_t path_len = strlen(cwd) + 1 + strlen(dump_file) + 1;
uint32_t total_len = sizeof(struct recorder_command_base) + path_len;
struct {
diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c
index ad5ee6a6..3e53c6d9 100644
--- a/tools/intel_gvtg_test.c
+++ b/tools/intel_gvtg_test.c
@@ -55,6 +55,10 @@
#include <limits.h>
#include <dirent.h>
+#ifdef __FreeBSD__
+#include <sys/wait.h>
+#endif
+
#define RANDOM(x) (rand() % x)
--
2.37.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility
2022-09-02 14:50 ` Jake Freeland
@ 2022-09-05 9:06 ` Petri Latvala
0 siblings, 0 replies; 20+ messages in thread
From: Petri Latvala @ 2022-09-05 9:06 UTC (permalink / raw)
To: Jake Freeland; +Cc: igt-dev
On Fri, Sep 02, 2022 at 09:50:18AM -0500, Jake Freeland wrote:
> Hi there,
>
> I am considering bundling all FreeBSD-specific igt macros into an
> `igt_freebsd.h` header
> for greater accessibility. If this idea is acceptable, I need a place to
> create this file.
> What's the appropriate location for an igt-specific header that does not
> have a corresponding
> source file?
lib/igt_freebsd.h sounds good.
--
Petri Latvala
>
> Thank you,
> Jake Freeland
>
> On Fri, Sep 2, 2022 at 9:14 AM Jake Freeland <jake@technologyfriends.net>
> wrote:
>
> > Signed-off-by: Jake Freeland <jfree@freebsd.org>
> > ---
> > benchmarks/gem_exec_tracer.c | 4 +
> > benchmarks/gem_syslatency.c | 9 ++
> > include/linux-uapi/sync_file.h | 8 ++
> > lib/i915/gem_engine_topology.c | 4 +
> > lib/i915/gem_mman.c | 5 ++
> > lib/i915/intel_memory_region.c | 4 +
> > lib/i915/perf.c | 2 +
> > lib/igt_audio.c | 4 +
> > lib/igt_aux.c | 44 ++++++++++
> > lib/igt_aux.h | 6 +-
> > lib/igt_core.c | 16 +++-
> > lib/igt_core.h | 6 ++
> > lib/igt_debugfs.c | 6 ++
> > lib/igt_device.c | 2 +
> > lib/igt_device_scan.c | 4 +
> > lib/igt_eld.c | 4 +
> > lib/igt_frame.c | 4 +
> > lib/igt_kmod.c | 118 ++++++++++++++++++++++++++
> > lib/igt_kmod.h | 2 +
> > lib/igt_kms.c | 4 +
> > lib/igt_os.c | 19 +++++
> > lib/igt_perf.c | 58 +++++++++++++
> > lib/igt_perf.h | 4 +
> > lib/igt_pm.c | 2 +
> > lib/igt_syncobj.c | 4 +
> > lib/igt_sysfs.c | 2 +
> > lib/igt_vgem.c | 5 ++
> > lib/intel_allocator.c | 4 +
> > lib/intel_batchbuffer.c | 5 ++
> > lib/sw_sync.c | 4 +
> > lib/tests/igt_exit_handler.c | 4 +
> > lib/tests/igt_fork.c | 4 +
> > lib/tests/igt_tests_common.h | 9 ++
> > runner/executor.c | 14 +++
> > tests/core_auth.c | 4 +
> > tests/drm_import_export.c | 4 +
> > tests/dumb_buffer.c | 5 ++
> > tests/i915/gem_close_race.c | 6 ++
> > tests/i915/gem_concurrent_all.c | 5 ++
> > tests/i915/gem_create.c | 4 +
> > tests/i915/gem_ctx_exec.c | 4 +
> > tests/i915/gem_ctx_persistence.c | 4 +
> > tests/i915/gem_ctx_shared.c | 4 +
> > tests/i915/gem_exec_fence.c | 4 +
> > tests/i915/gem_exec_latency.c | 4 +
> > tests/i915/gem_lmem_swapping.c | 4 +
> > tests/i915/gem_madvise.c | 4 +
> > tests/i915/gem_mmap_gtt.c | 14 +++
> > tests/i915/gem_mmap_offset.c | 14 +++
> > tests/i915/gem_shrink.c | 4 +
> > tests/i915/gem_wait.c | 4 +
> > tests/i915/i915_hangman.c | 4 +
> > tests/i915/i915_module_load.c | 2 +
> > tests/i915/i915_pm_backlight.c | 4 +
> > tests/i915/i915_pm_rpm.c | 13 +++
> > tests/i915/sysfs_heartbeat_interval.c | 4 +
> > tests/kms_content_protection.c | 2 +
> > tests/kms_cursor_legacy.c | 4 +
> > tests/kms_flip.c | 4 +
> > tests/kms_sysfs_edid_timing.c | 4 +
> > tests/sw_sync.c | 3 +
> > tests/syncobj_timeline.c | 4 +
> > tests/syncobj_wait.c | 4 +
> > tests/tools_test.c | 5 ++
> > tests/vc4_purgeable_bo.c | 4 +
> > tests/vc4_wait_bo.c | 4 +
> > tests/vc4_wait_seqno.c | 4 +
> > tools/intel_gvtg_test.c | 3 +
> > 68 files changed, 552 insertions(+), 6 deletions(-)
> >
> > diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
> > index e6973991..084c8e65 100644
> > --- a/benchmarks/gem_exec_tracer.c
> > +++ b/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/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
> > index 035ee934..be92ff0f 100644
> > --- a/benchmarks/gem_syslatency.c
> > +++ b/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/include/linux-uapi/sync_file.h
> > b/include/linux-uapi/sync_file.h
> > index b4f2db00..0f1fb720 100644
> > --- a/include/linux-uapi/sync_file.h
> > +++ b/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/lib/i915/gem_engine_topology.c
> > b/lib/i915/gem_engine_topology.c
> > index ca3333c2..9d574de5 100644
> > --- a/lib/i915/gem_engine_topology.c
> > +++ b/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/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
> > index aa9ac6f3..7bd6f22b 100644
> > --- a/lib/i915/gem_mman.c
> > +++ b/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/lib/i915/intel_memory_region.c
> > b/lib/i915/intel_memory_region.c
> > index 93a18982..88b2667b 100644
> > --- a/lib/i915/intel_memory_region.c
> > +++ b/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/lib/i915/perf.c b/lib/i915/perf.c
> > index d88835ff..beda6b8a 100644
> > --- a/lib/i915/perf.c
> > +++ b/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/lib/igt_audio.c b/lib/igt_audio.c
> > index e0b1bafe..201a39c6 100644
> > --- a/lib/igt_audio.c
> > +++ b/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/lib/igt_aux.c b/lib/igt_aux.c
> > index edb53425..e6b2bd7e 100644
> > --- a/lib/igt_aux.c
> > +++ b/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/lib/igt_aux.h b/lib/igt_aux.h
> > index c8d487b6..912f36c1 100644
> > --- a/lib/igt_aux.h
> > +++ b/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/lib/igt_core.c b/lib/igt_core.c
> > index e7425326..23f703f3 100644
> > --- a/lib/igt_core.c
> > +++ b/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 print_usage(const char *help_str, bool
> > output_on_stderr)
> >
> > 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/lib/igt_core.h b/lib/igt_core.h
> > index aa98e8ed..7869f722 100644
> > --- a/lib/igt_core.h
> > +++ b/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/lib/igt_debugfs.c b/lib/igt_debugfs.c
> > index a56688a5..b7e37851 100644
> > --- a/lib/igt_debugfs.c
> > +++ b/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>
> > @@ -43,6 +45,10 @@
> > #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
> > * @short_description: Support code for debugfs features
> > diff --git a/lib/igt_device.c b/lib/igt_device.c
> > index fddfba72..49b77122 100644
> > --- a/lib/igt_device.c
> > +++ b/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/lib/igt_device_scan.c b/lib/igt_device_scan.c
> > index eb6b45b8..6a921d52 100644
> > --- a/lib/igt_device_scan.c
> > +++ b/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/lib/igt_eld.c b/lib/igt_eld.c
> > index ef6625df..e05ad6de 100644
> > --- a/lib/igt_eld.c
> > +++ b/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/lib/igt_frame.c b/lib/igt_frame.c
> > index 45523a79..ab74e678 100644
> > --- a/lib/igt_frame.c
> > +++ b/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/lib/igt_kmod.c b/lib/igt_kmod.c
> > index bcf7dfeb..12a22a95 100644
> > --- a/lib/igt_kmod.c
> > +++ b/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/lib/igt_kmod.h b/lib/igt_kmod.h
> > index f98dd29f..6596092b 100644
> > --- a/lib/igt_kmod.h
> > +++ b/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/lib/igt_kms.c b/lib/igt_kms.c
> > index 1ba3bd2a..f0208c10 100644
> > --- a/lib/igt_kms.c
> > +++ b/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/lib/igt_os.c b/lib/igt_os.c
> > index bdd5d933..ae426e3a 100644
> > --- a/lib/igt_os.c
> > +++ b/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/lib/igt_perf.c b/lib/igt_perf.c
> > index b743859f..90edbbd0 100644
> > --- a/lib/igt_perf.c
> > +++ b/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, int group)
> > 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)
> > +{
> > + return strerror(ENOSYS);
> > +}
> > +
> > +uint64_t
> > +i915_perf_type_id(int i915)
> > +{
> > + return -ENOSYS;
> > +}
> > +
> > +int
> > +perf_igfx_open(uint64_t config)
> > +{
> > + return -ENOSYS;
> > +}
> > +
> > +int
> > +perf_igfx_open_group(uint64_t config, int group)
> > +{
> > + return -ENOSYS;
> > +}
> > +
> > +int
> > +perf_i915_open(int i915, uint64_t config)
> > +{
> > + return -ENOSYS;
> > +}
> > +
> > +int
> > +perf_i915_open_group(int i915, uint64_t config, int group)
> > +{
> > + return -ENOSYS;
> > +}
> > +#endif /* __linux__ */
> > diff --git a/lib/igt_perf.h b/lib/igt_perf.h
> > index a8328c70..0cd91386 100644
> > --- a/lib/igt_perf.h
> > +++ b/lib/igt_perf.h
> > @@ -27,10 +27,13 @@
> >
> > #include <stdint.h>
> >
> > +#ifdef __linux__
> > #include <linux/perf_event.h>
> > +#endif
> >
> > #include "igt_gt.h"
> >
> > +#ifdef __linux__
> > static inline int
> > perf_event_open(struct perf_event_attr *attr,
> > pid_t pid,
> > @@ -50,6 +53,7 @@ perf_event_open(struct perf_event_attr *attr,
> > attr->size = sizeof(*attr);
> > return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);
> > }
> > +#endif /* __linux__ */
> >
> > uint64_t igt_perf_type_id(const char *device);
> > int igt_perf_open(uint64_t type, uint64_t config);
> > diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> > index 99251b40..a6036e03 100644
> > --- a/lib/igt_pm.c
> > +++ b/lib/igt_pm.c
> > @@ -33,7 +33,9 @@
> > #include <string.h>
> > #include <unistd.h>
> > #include <sys/stat.h>
> > +#ifdef __linux__
> > #include <sys/sysmacros.h>
> > +#endif
> > #include <sys/types.h>
> > #include <dirent.h>
> >
> > diff --git a/lib/igt_syncobj.c b/lib/igt_syncobj.c
> > index a24ed10b..eb302986 100644
> > --- a/lib/igt_syncobj.c
> > +++ b/lib/igt_syncobj.c
> > @@ -27,6 +27,10 @@
> > #include "igt.h"
> > #include "igt_syncobj.h"
> >
> > +#ifdef __FreeBSD__
> > +#define ETIME ETIMEDOUT
> > +#endif
> > +
> > /**
> > * SECTION:igt_syncobj
> > * @short_description: Library with syncobj helpers
> > diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
> > index 9c307694..a913be4c 100644
> > --- a/lib/igt_sysfs.c
> > +++ b/lib/igt_sysfs.c
> > @@ -24,7 +24,9 @@
> >
> > #include <inttypes.h>
> > #include <sys/stat.h>
> > +#ifdef __linux__
> > #include <sys/sysmacros.h>
> > +#endif
> > #include <sys/mount.h>
> > #include <errno.h>
> > #include <stdarg.h>
> > diff --git a/lib/igt_vgem.c b/lib/igt_vgem.c
> > index 7f933b23..9483b896 100644
> > --- a/lib/igt_vgem.c
> > +++ b/lib/igt_vgem.c
> > @@ -30,6 +30,11 @@
> > #include "igt_core.h"
> > #include "ioctl_wrappers.h"
> >
> > +#ifdef __FreeBSD__
> > +#define mmap64(addr, len, prot, flags, fd, offset) \
> > + mmap(addr, len, prot, flags, fd, offset)
> > +#endif
> > +
> > /**
> > * SECTION:igt_vgem
> > * @short_description: VGEM support library
> > diff --git a/lib/intel_allocator.c b/lib/intel_allocator.c
> > index 717d7fc5..bd840f57 100644
> > --- a/lib/intel_allocator.c
> > +++ b/lib/intel_allocator.c
> > @@ -17,6 +17,10 @@
> > #include "intel_allocator.h"
> > #include "intel_allocator_msgchannel.h"
> >
> > +#ifdef __FreeBSD__
> > +#define gettid() getpid()
> > +#endif
> > +
> > //#define ALLOCDBG
> > #ifdef ALLOCDBG
> > #define alloc_info igt_info
> > diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
> > index ef1b5947..8004c09e 100644
> > --- a/lib/intel_batchbuffer.c
> > +++ b/lib/intel_batchbuffer.c
> > @@ -60,6 +60,11 @@
> > #define BCS_SRC_Y (1 << 0)
> > #define BCS_DST_Y (1 << 1)
> >
> > +#ifdef __FreeBSD__
> > +/* memory leak */
> > +#define tdestroy(root, free_node)
> > +#endif
> > +
> > /**
> > * SECTION:intel_batchbuffer
> > * @short_description: Batchbuffer and blitter support
> > diff --git a/lib/sw_sync.c b/lib/sw_sync.c
> > index 6c762c8b..e5a73ffa 100644
> > --- a/lib/sw_sync.c
> > +++ b/lib/sw_sync.c
> > @@ -41,6 +41,10 @@
> > #include "drmtest.h"
> > #include "ioctl_wrappers.h"
> >
> > +#ifdef __FreeBSD__
> > +#define ETIME ETIMEDOUT
> > +#endif
> > +
> > /**
> > * SECTION:sw_sync
> > * @short_description: Software sync (fencing) support library
> > diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
> > index 892a7f14..d2381944 100644
> > --- a/lib/tests/igt_exit_handler.c
> > +++ b/lib/tests/igt_exit_handler.c
> > @@ -125,5 +125,9 @@ int main(int argc, char **argv)
> > internal_assert_wexited(status, IGT_EXIT_SKIP);
> >
> > status = testfunc(SIG);
> > +#ifdef __linux__
> > internal_assert_wsignaled(status, SIGTERM);
> > +#elif defined(__FreeBSD__)
> > + internal_assert(status == 0);
> > +#endif
> > }
> > diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
> > index d19d0945..4a2d50d4 100644
> > --- a/lib/tests/igt_fork.c
> > +++ b/lib/tests/igt_fork.c
> > @@ -109,7 +109,11 @@ __noreturn static void igt_fork_timeout_leak(void)
> > __noreturn static void subtest_leak(void)
> > {
> > pid_t *children =
> > +#ifdef __linux__
> > mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
> > +#elif defined(__FreeBSD__)
> > + mmap(0, 4096, PROT_WRITE | PROT_READ, MAP_SHARED |
> > MAP_ANON, -1, 0);
> > +#endif
> > const int num_children = 4096 / sizeof(*children);
> >
> > igt_subtest_init(fake_argc, fake_argv);
> > diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
> > index 058f6265..e8183897 100644
> > --- a/lib/tests/igt_tests_common.h
> > +++ b/lib/tests/igt_tests_common.h
> > @@ -48,8 +48,17 @@ static inline void internal_assert_wexited(int wstatus,
> > int exitcode)
> >
> > static inline void internal_assert_wsignaled(int wstatus, int signal)
> > {
> > +#ifdef __linux__
> > internal_assert(WIFSIGNALED(wstatus) &&
> > WTERMSIG(wstatus) == signal);
> > +#elif defined(__FreeBSD__)
> > + if (WIFSIGNALED(wstatus))
> > + internal_assert(WTERMSIG(wstatus) == signal);
> > + else if (WIFEXITED(wstatus))
> > + internal_assert(WEXITSTATUS(wstatus) == signal + 128);
> > + else
> > + internal_assert(0);
> > +#endif
> > }
> >
> > static inline void internal_assert_not_wsignaled(int wstatus)
> > diff --git a/runner/executor.c b/runner/executor.c
> > index 964d0063..65e3d2ba 100644
> > --- a/runner/executor.c
> > +++ b/runner/executor.c
> > @@ -2,7 +2,9 @@
> > #include <errno.h>
> > #include <fcntl.h>
> > #include <glib.h>
> > +#ifdef __linux__
> > #include <linux/watchdog.h>
> > +#endif
> > #if HAVE_OPING
> > #include <oping.h>
> > #endif
> > @@ -14,7 +16,9 @@
> > #include <sys/ioctl.h>
> > #include <sys/select.h>
> > #include <sys/poll.h>
> > +#ifdef __linux__
> > #include <sys/signalfd.h>
> > +#endif
> > #include <sys/stat.h>
> > #include <sys/time.h>
> > #include <sys/types.h>
> > @@ -33,6 +37,16 @@
> > #define KMSG_HEADER "[IGT] "
> > #define KMSG_WARN 4
> >
> > +#ifdef __FreeBSD__
> > +#include <sys/watchdog.h>
> > +struct signalfd_siginfo {
> > + uint32_t ssi_signo;
> > + uint32_t ssi_pid;
> > +};
> > +#define WDIOC_KEEPALIVE WDIOCPATPAT
> > +#define signalfd(fd, mask, flags) -ENOSYS
> > +#endif
> > +
> > static struct {
> > int *fds;
> > size_t num_dogs;
> > diff --git a/tests/core_auth.c b/tests/core_auth.c
> > index c9ad3fb9..fdd46e92 100644
> > --- a/tests/core_auth.c
> > +++ b/tests/core_auth.c
> > @@ -48,6 +48,10 @@
> > # include <pthread.h>
> > #endif
> >
> > +#ifdef __FreeBSD__
> > +#define pthread_self() getpid()
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("Call drmGetMagic() and drmAuthMagic() and see if it
> > behaves.");
> >
> > static bool
> > diff --git a/tests/drm_import_export.c b/tests/drm_import_export.c
> > index 06245e8b..448d2d70 100644
> > --- a/tests/drm_import_export.c
> > +++ b/tests/drm_import_export.c
> > @@ -45,6 +45,10 @@
> > #define DURATION 10
> > IGT_TEST_DESCRIPTION("Basic check to verify the behaviour of libdrm bo
> > for prime/flink");
> >
> > +#ifdef __FreeBSD__
> > +#define gettid() getpid()
> > +#endif
> > +
> > int fd;
> > drm_intel_bufmgr *bufmgr;
> > int fd1;
> > diff --git a/tests/dumb_buffer.c b/tests/dumb_buffer.c
> > index 2c6261bd..e5278a90 100644
> > --- a/tests/dumb_buffer.c
> > +++ b/tests/dumb_buffer.c
> > @@ -50,6 +50,11 @@
> > #include "igt_aux.h"
> > #include "ioctl_wrappers.h"
> >
> > +#ifdef __FreeBSD__
> > +#undef jmp_buf
> > +#define sighandler_t sig_t
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("This is a test for the generic dumb buffer
> > interface.");
> >
> > static int __dumb_create(int fd, struct drm_mode_create_dumb *create)
> > diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
> > index 938fde8f..0b7378b2 100644
> > --- a/tests/i915/gem_close_race.c
> > +++ b/tests/i915/gem_close_race.c
> > @@ -53,6 +53,10 @@
> > #define BLT_WRITE_ALPHA (1<<21)
> > #define BLT_WRITE_RGB (1<<20)
> >
> > +#ifdef __FreeBSD__
> > +#define gettid() getpid()
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("Test try to race gem_close against workload
> > submission.");
> >
> > static uint32_t devid;
> > @@ -61,7 +65,9 @@ static bool has_softpin;
> > static uint64_t exec_addr;
> > static uint64_t data_addr;
> >
> > +#ifdef __linux__
> > #define sigev_notify_thread_id _sigev_un._tid
> > +#endif
> >
> > static void selfcopy(int fd, uint32_t ctx, uint32_t handle, int loops)
> > {
> > diff --git a/tests/i915/gem_concurrent_all.c
> > b/tests/i915/gem_concurrent_all.c
> > index 25b7daf8..e965dadb 100644
> > --- a/tests/i915/gem_concurrent_all.c
> > +++ b/tests/i915/gem_concurrent_all.c
> > @@ -53,6 +53,11 @@
> > #include "igt.h"
> > #include "igt_vgem.h"
> >
> > +/* improper substitution */
> > +#ifdef __FreeBSD__
> > +#define MADV_DONTFORK MADV_NOSYNC
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("Test of pread/pwrite/mmap behavior when writing to
> > active"
> > " buffers.");
> >
> > diff --git a/tests/i915/gem_create.c b/tests/i915/gem_create.c
> > index d7d2a017..18d9324e 100644
> > --- a/tests/i915/gem_create.c
> > +++ b/tests/i915/gem_create.c
> > @@ -61,6 +61,10 @@
> > #include "i915/gem_mman.h"
> > #include "i915_drm.h"
> >
> > +#ifdef __FreeBSD__
> > +#define sighandler_t sig_t
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("Ensure that basic gem_create and gem_create_ext
> > works"
> > " and that invalid input combinations are rejected.");
> >
> > diff --git a/tests/i915/gem_ctx_exec.c b/tests/i915/gem_ctx_exec.c
> > index 3d94f01d..3cc7a87c 100644
> > --- a/tests/i915/gem_ctx_exec.c
> > +++ b/tests/i915/gem_ctx_exec.c
> > @@ -48,6 +48,10 @@
> > #include "igt_sysfs.h"
> > #include "sw_sync.h"
> >
> > +#ifdef __FreeBSD__
> > +#define ETIME ETIMEDOUT
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("Test context batch buffer execution.");
> >
> > /* Copied from gem_exec_nop.c */
> > diff --git a/tests/i915/gem_ctx_persistence.c
> > b/tests/i915/gem_ctx_persistence.c
> > index 50196edb..afda4675 100644
> > --- a/tests/i915/gem_ctx_persistence.c
> > +++ b/tests/i915/gem_ctx_persistence.c
> > @@ -50,6 +50,10 @@
> > static unsigned long reset_timeout_ms = RESET_TIMEOUT_MS;
> > #define NSEC_PER_MSEC (1000 * 1000ull)
> >
> > +#ifdef __FreeBSD__
> > +#define ETIME ETIMEDOUT
> > +#endif
> > +
> > static void cleanup(int i915)
> > {
> > igt_drop_caches_set(i915,
> > diff --git a/tests/i915/gem_ctx_shared.c b/tests/i915/gem_ctx_shared.c
> > index eb3b024f..fe1c788b 100644
> > --- a/tests/i915/gem_ctx_shared.c
> > +++ b/tests/i915/gem_ctx_shared.c
> > @@ -54,6 +54,10 @@
> > #define MAX_PRIO I915_CONTEXT_MAX_USER_PRIORITY
> > #define MIN_PRIO I915_CONTEXT_MIN_USER_PRIORITY
> >
> > +#ifdef __FreeBSD__
> > +#define ETIME ETIMEDOUT
> > +#endif
> > +
> > static int priorities[] = {
> > [LO] = MIN_PRIO / 2,
> > [HI] = MAX_PRIO / 2,
> > diff --git a/tests/i915/gem_exec_fence.c b/tests/i915/gem_exec_fence.c
> > index f24bebdb..50b14c87 100644
> > --- a/tests/i915/gem_exec_fence.c
> > +++ b/tests/i915/gem_exec_fence.c
> > @@ -36,6 +36,10 @@
> > #include "intel_ctx.h"
> > #include "sw_sync.h"
> >
> > +#ifdef __FreeBSD__
> > +#define ETIME ETIMEDOUT
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("Check that execbuf waits for explicit fences");
> >
> > #ifndef SYNC_IOC_MERGE
> > diff --git a/tests/i915/gem_exec_latency.c b/tests/i915/gem_exec_latency.c
> > index fcdf7787..dad9ea27 100644
> > --- a/tests/i915/gem_exec_latency.c
> > +++ b/tests/i915/gem_exec_latency.c
> > @@ -55,6 +55,10 @@
> > #define CORK 0x2
> > #define PREEMPT 0x4
> >
> > +#ifdef __FreeBSD__
> > +#define SCHED_RESET_ON_FORK 0
> > +#endif
> > +
> > static unsigned int ring_size;
> > static double rcs_clock;
> > static struct intel_mmio_data mmio_data;
> > diff --git a/tests/i915/gem_lmem_swapping.c
> > b/tests/i915/gem_lmem_swapping.c
> > index cccdb319..34ca455f 100644
> > --- a/tests/i915/gem_lmem_swapping.c
> > +++ b/tests/i915/gem_lmem_swapping.c
> > @@ -25,6 +25,10 @@
> > #include "i915/i915_blt.h"
> > #include "i915/intel_mocs.h"
> >
> > +#ifdef __FreeBSD__
> > +#define MAP_POPULATE MAP_PREFAULT_READ
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("Exercise local memory swapping.");
> >
> > #define __round_mask(x, y) ((__typeof__(x))((y) - 1))
> > diff --git a/tests/i915/gem_madvise.c b/tests/i915/gem_madvise.c
> > index 2502d84c..4c6cdbc4 100644
> > --- a/tests/i915/gem_madvise.c
> > +++ b/tests/i915/gem_madvise.c
> > @@ -39,6 +39,10 @@
> > #include "drm.h"
> > #include "i915/gem_create.h"
> >
> > +#ifdef __FreeBSD__
> > +#define sighandler_t sig_t
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("Checks that the kernel reports EFAULT when trying
> > to use"
> > " purged bo.");
> >
> > diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
> > index e39b9047..8daa6248 100644
> > --- a/tests/i915/gem_mmap_gtt.c
> > +++ b/tests/i915/gem_mmap_gtt.c
> > @@ -54,6 +54,16 @@
> >
> > #define abs(x) ((x) >= 0 ? (x) : -(x))
> >
> > +#ifdef __FreeBSD__
> > +#define mmap64(addr, len, prot, flags, fd, offset) \
> > + mmap(addr, len, prot, flags, fd, offset)
> > +#define PTRACE_TRACEME PT_TRACE_ME
> > +#define PTRACE_ATTACH PT_ATTACH
> > +#define PTRACE_PEEKDATA PT_READ_D
> > +#define PTRACE_POKEDATA PT_WRITE_D
> > +#define PTRACE_DETACH PT_DETACH
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("Ensure that all operations around MMAP_GTT ioctl
> > works.");
> >
> > static int OBJECT_SIZE = 16*1024*1024;
> > @@ -566,7 +576,11 @@ test_ptrace(int fd)
> > for (int i = 0; i < sz / sizeof(long); i++) {
> > long ret;
> >
> > +#ifdef __linux__
> > ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i);
> > +#elif defined(__FreeBSD__)
> > + ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i, 0);
> > +#endif
> > igt_assert_eq_u64(ret, CC);
> > cpy[i] = ret;
> >
> > diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
> > index 5e6b19eb..21bcdddd 100644
> > --- a/tests/i915/gem_mmap_offset.c
> > +++ b/tests/i915/gem_mmap_offset.c
> > @@ -38,6 +38,16 @@
> > #include "igt.h"
> > #include "igt_x86.h"
> >
> > +#ifdef __FreeBSD__
> > +#define mmap64(addr, len, prot, flags, fd, offset) \
> > + mmap(addr, len, prot, flags, fd, offset)
> > +#define PTRACE_TRACEME PT_TRACE_ME
> > +#define PTRACE_ATTACH PT_ATTACH
> > +#define PTRACE_PEEKDATA PT_READ_D
> > +#define PTRACE_POKEDATA PT_WRITE_D
> > +#define PTRACE_DETACH PT_DETACH
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("Basic MMAP_OFFSET IOCTL tests for mem regions\n");
> >
> > static int mmap_offset_ioctl(int i915, struct drm_i915_gem_mmap_offset
> > *arg)
> > @@ -370,7 +380,11 @@ static void test_ptrace(int i915)
> > for (int i = 0; i < SZ / sizeof(long); i++) {
> > long ret;
> >
> > +#ifdef __linux__
> > ret = ptrace(PTRACE_PEEKDATA, pid, ptr +
> > i);
> > +#elif defined(__FreeBSD__)
> > + ret = ptrace(PTRACE_PEEKDATA, pid, ptr +
> > i, 0);
> > +#endif
> > igt_assert_eq_u64(ret, CC);
> > cpy[i] = ret;
> >
> > diff --git a/tests/i915/gem_shrink.c b/tests/i915/gem_shrink.c
> > index 49df35c2..e9dd49cf 100644
> > --- a/tests/i915/gem_shrink.c
> > +++ b/tests/i915/gem_shrink.c
> > @@ -38,6 +38,10 @@
> > #define MADV_FREE 8
> > #endif
> >
> > +#ifdef __FreeBSD__
> > +#define MAP_POPULATE MAP_PREFAULT_READ
> > +#endif
> > +
> > static void get_pages(int fd, uint64_t alloc)
> > {
> > uint32_t handle = gem_create(fd, alloc);
> > diff --git a/tests/i915/gem_wait.c b/tests/i915/gem_wait.c
> > index 230304aa..9655fb09 100644
> > --- a/tests/i915/gem_wait.c
> > +++ b/tests/i915/gem_wait.c
> > @@ -32,6 +32,10 @@
> > #include "igt.h"
> > #include "igt_vgem.h"
> >
> > +#ifdef __FreeBSD__
> > +#define ETIME ETIMEDOUT
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("Tests the GEM_WAIT ioctl");
> >
> > static int __gem_wait(int fd, struct drm_i915_gem_wait *w)
> > diff --git a/tests/i915/i915_hangman.c b/tests/i915/i915_hangman.c
> > index c7d69fdd..c0bde6be 100644
> > --- a/tests/i915/i915_hangman.c
> > +++ b/tests/i915/i915_hangman.c
> > @@ -50,6 +50,10 @@ static int sysfs = -1;
> >
> > #define OFFSET_ALIVE 10
> >
> > +#ifdef __FreeBSD__
> > +#define ETIME ETIMEDOUT
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("Tests for hang detection and recovery");
> >
> > static void check_alive(void)
> > diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c
> > index 4c72157c..9bec4c18 100644
> > --- a/tests/i915/i915_module_load.c
> > +++ b/tests/i915/i915_module_load.c
> > @@ -23,7 +23,9 @@
> > #include "igt.h"
> > #include <dirent.h>
> > #include <sys/utsname.h>
> > +#ifdef __linux__
> > #include <linux/limits.h>
> > +#endif
> > #include <signal.h>
> > #include <libgen.h>
> > #include <signal.h>
> > diff --git a/tests/i915/i915_pm_backlight.c
> > b/tests/i915/i915_pm_backlight.c
> > index cafae7f7..c520cf20 100644
> > --- a/tests/i915/i915_pm_backlight.c
> > +++ b/tests/i915/i915_pm_backlight.c
> > @@ -46,6 +46,10 @@ struct context {
> > #define FADESTEPS 10
> > #define FADESPEED 100 /* milliseconds between steps */
> >
> > +#ifdef __FreeBSD__
> > +#include <libgen.h>
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
> >
> > static int backlight_read(int *result, const char *fname)
> > diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
> > index e95875dc..6a30ecf6 100644
> > --- a/tests/i915/i915_pm_rpm.c
> > +++ b/tests/i915/i915_pm_rpm.c
> > @@ -40,8 +40,10 @@
> > #include <sys/mman.h>
> > #include <sys/types.h>
> > #include <sys/stat.h>
> > +#ifdef __linux__
> > #include <linux/i2c.h>
> > #include <linux/i2c-dev.h>
> > +#endif
> >
> > #include <drm.h>
> >
> > @@ -54,6 +56,17 @@
> > #include "igt_device.h"
> > #include "igt_edid.h"
> >
> > +#ifdef __FreeBSD__
> > +#include <limits.h>
> > +#include <dev/iicbus/iic.h>
> > +
> > +#define I2C_RDWR I2CRDWR
> > +#define I2C_M_RD IIC_M_RD
> > +#define i2c_msg iic_msg
> > +#define i2c_rdwr_ioctl_data iic_rdwr_data
> > +#define addr slave
> > +#endif
> > +
> > #define MSR_PC8_RES 0x630
> > #define MSR_PC9_RES 0x631
> > #define MSR_PC10_RES 0x632
> > diff --git a/tests/i915/sysfs_heartbeat_interval.c
> > b/tests/i915/sysfs_heartbeat_interval.c
> > index 8cebf627..cb1f37f8 100644
> > --- a/tests/i915/sysfs_heartbeat_interval.c
> > +++ b/tests/i915/sysfs_heartbeat_interval.c
> > @@ -42,6 +42,10 @@
> > #include "igt_sysfs.h"
> > #include "sw_sync.h"
> >
> > +#ifdef __FreeBSD__
> > +#define sighandler_t sig_t
> > +#endif
> > +
> > #define ATTR "heartbeat_interval_ms"
> > #define RESET_TIMEOUT 50 /* milliseconds, at least one jiffie for kworker
> > */
> >
> > diff --git a/tests/kms_content_protection.c
> > b/tests/kms_content_protection.c
> > index 3041f1cd..e0e5af78 100644
> > --- a/tests/kms_content_protection.c
> > +++ b/tests/kms_content_protection.c
> > @@ -24,7 +24,9 @@
> >
> > #include <poll.h>
> > #include <fcntl.h>
> > +#ifdef __linux__
> > #include <sys/epoll.h>
> > +#endif
> > #include <sys/stat.h>
> > #include <libudev.h>
> > #include "igt.h"
> > diff --git a/tests/kms_cursor_legacy.c b/tests/kms_cursor_legacy.c
> > index 1b697667..67a470b6 100644
> > --- a/tests/kms_cursor_legacy.c
> > +++ b/tests/kms_cursor_legacy.c
> > @@ -47,6 +47,10 @@
> >
> > #define PAGE_SIZE 4096
> >
> > +#ifdef __FreeBSD__
> > +#define SCHED_IDLE SCHED_OTHER
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("Stress legacy cursor ioctl");
> >
> > igt_pipe_crc_t *pipe_crc;
> > diff --git a/tests/kms_flip.c b/tests/kms_flip.c
> > index 0567edea..1127e418 100755
> > --- a/tests/kms_flip.c
> > +++ b/tests/kms_flip.c
> > @@ -45,6 +45,10 @@
> > #include "i915/gem_create.h"
> > #include "igt_stats.h"
> >
> > +#ifdef __FreeBSD__
> > +#include <sys/consio.h>
> > +#endif
> > +
> > #define TEST_DPMS (1 << 0)
> >
> > #define TEST_PAN (1 << 3)
> > diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
> > index 77521108..cd980c6a 100644
> > --- a/tests/kms_sysfs_edid_timing.c
> > +++ b/tests/kms_sysfs_edid_timing.c
> > @@ -26,6 +26,10 @@
> > #include <fcntl.h>
> > #include <sys/stat.h>
> >
> > +#ifdef __FreeBSD__
> > +#include <limits.h>
> > +#endif
> > +
> > #define THRESHOLD_PER_CONNECTOR 150
> > #define THRESHOLD_PER_CONNECTOR_MEAN 140
> > #define THRESHOLD_ALL_CONNECTORS_MEAN 100
> > diff --git a/tests/sw_sync.c b/tests/sw_sync.c
> > index cbd773fc..1290a284 100644
> > --- a/tests/sw_sync.c
> > +++ b/tests/sw_sync.c
> > @@ -38,6 +38,9 @@
> >
> > #include "sw_sync.h"
> >
> > +#ifdef __FreeBSD__
> > +#define ETIME ETIMEDOUT
> > +#endif
> >
> > IGT_TEST_DESCRIPTION("Test SW Sync Framework");
> >
> > diff --git a/tests/syncobj_timeline.c b/tests/syncobj_timeline.c
> > index 20375cdd..795fd3fb 100644
> > --- a/tests/syncobj_timeline.c
> > +++ b/tests/syncobj_timeline.c
> > @@ -31,6 +31,10 @@
> > #include <signal.h>
> > #include "drm.h"
> >
> > +#ifdef __FreeBSD__
> > +#define ETIME ETIMEDOUT
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("Tests for the drm timeline sync object API");
> >
> > /* One tenth of a second */
> > diff --git a/tests/syncobj_wait.c b/tests/syncobj_wait.c
> > index 669d0adf..4f31fb76 100644
> > --- a/tests/syncobj_wait.c
> > +++ b/tests/syncobj_wait.c
> > @@ -31,6 +31,10 @@
> > #include <signal.h>
> > #include "drm.h"
> >
> > +#ifdef __FreeBSD__
> > +#define ETIME ETIMEDOUT
> > +#endif
> > +
> > IGT_TEST_DESCRIPTION("Tests for the drm sync object wait API");
> >
> > /* One tenth of a second */
> > diff --git a/tests/tools_test.c b/tests/tools_test.c
> > index 237f0433..6652927a 100644
> > --- a/tests/tools_test.c
> > +++ b/tests/tools_test.c
> > @@ -28,7 +28,12 @@
> > #include <fcntl.h>
> > #include <libgen.h>
> > #include <unistd.h>
> > +#ifdef __linux__
> > #include <linux/limits.h>
> > +#elif defined(__FreeBSD__)
> > +#include <limits.h>
> > +#define get_current_dir_name() getwd(NULL)
> > +#endif
> >
> > #define TOOLS "../tools/"
> >
> > diff --git a/tests/vc4_purgeable_bo.c b/tests/vc4_purgeable_bo.c
> > index d9f7547f..5aa734b4 100644
> > --- a/tests/vc4_purgeable_bo.c
> > +++ b/tests/vc4_purgeable_bo.c
> > @@ -35,6 +35,10 @@
> > #include <sys/ioctl.h>
> > #include "vc4_drm.h"
> >
> > +#ifdef __FreeBSD__
> > +#undef jmp_buf
> > +#endif
> > +
> > struct igt_vc4_bo {
> > struct igt_list_head node;
> > int handle;
> > diff --git a/tests/vc4_wait_bo.c b/tests/vc4_wait_bo.c
> > index 65a085a3..2c3c9da8 100644
> > --- a/tests/vc4_wait_bo.c
> > +++ b/tests/vc4_wait_bo.c
> > @@ -34,6 +34,10 @@
> > #include <sys/ioctl.h>
> > #include "vc4_drm.h"
> >
> > +#ifdef __FreeBSD__
> > +#define ETIME ETIMEDOUT
> > +#endif
> > +
> > static void
> > test_used_bo(int fd, uint64_t timeout)
> > {
> > diff --git a/tests/vc4_wait_seqno.c b/tests/vc4_wait_seqno.c
> > index bcc263cb..c04c8d78 100644
> > --- a/tests/vc4_wait_seqno.c
> > +++ b/tests/vc4_wait_seqno.c
> > @@ -33,6 +33,10 @@
> > #include <sys/ioctl.h>
> > #include "vc4_drm.h"
> >
> > +#ifdef __FreeBSD__
> > +#define ETIME ETIMEDOUT
> > +#endif
> > +
> > igt_main
> > {
> > int fd;
> > diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c
> > index ad5ee6a6..2f0c94f0 100644
> > --- a/tools/intel_gvtg_test.c
> > +++ b/tools/intel_gvtg_test.c
> > @@ -44,6 +44,9 @@
> > #include <sys/ioctl.h>
> > #include <sys/types.h>
> > #include <sys/stat.h>
> > +#ifdef __FreeBSD__
> > +#include <sys/wait.h>
> > +#endif
> > #include <string.h>
> > #include <stdlib.h>
> > #include <signal.h>
> > --
> > 2.37.2
> >
> >
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility
2022-09-02 14:14 Jake Freeland
@ 2022-09-02 14:50 ` Jake Freeland
2022-09-05 9:06 ` Petri Latvala
0 siblings, 1 reply; 20+ messages in thread
From: Jake Freeland @ 2022-09-02 14:50 UTC (permalink / raw)
To: igt-dev
[-- Attachment #1: Type: text/plain, Size: 43502 bytes --]
Hi there,
I am considering bundling all FreeBSD-specific igt macros into an
`igt_freebsd.h` header
for greater accessibility. If this idea is acceptable, I need a place to
create this file.
What's the appropriate location for an igt-specific header that does not
have a corresponding
source file?
Thank you,
Jake Freeland
On Fri, Sep 2, 2022 at 9:14 AM Jake Freeland <jake@technologyfriends.net>
wrote:
> Signed-off-by: Jake Freeland <jfree@freebsd.org>
> ---
> benchmarks/gem_exec_tracer.c | 4 +
> benchmarks/gem_syslatency.c | 9 ++
> include/linux-uapi/sync_file.h | 8 ++
> lib/i915/gem_engine_topology.c | 4 +
> lib/i915/gem_mman.c | 5 ++
> lib/i915/intel_memory_region.c | 4 +
> lib/i915/perf.c | 2 +
> lib/igt_audio.c | 4 +
> lib/igt_aux.c | 44 ++++++++++
> lib/igt_aux.h | 6 +-
> lib/igt_core.c | 16 +++-
> lib/igt_core.h | 6 ++
> lib/igt_debugfs.c | 6 ++
> lib/igt_device.c | 2 +
> lib/igt_device_scan.c | 4 +
> lib/igt_eld.c | 4 +
> lib/igt_frame.c | 4 +
> lib/igt_kmod.c | 118 ++++++++++++++++++++++++++
> lib/igt_kmod.h | 2 +
> lib/igt_kms.c | 4 +
> lib/igt_os.c | 19 +++++
> lib/igt_perf.c | 58 +++++++++++++
> lib/igt_perf.h | 4 +
> lib/igt_pm.c | 2 +
> lib/igt_syncobj.c | 4 +
> lib/igt_sysfs.c | 2 +
> lib/igt_vgem.c | 5 ++
> lib/intel_allocator.c | 4 +
> lib/intel_batchbuffer.c | 5 ++
> lib/sw_sync.c | 4 +
> lib/tests/igt_exit_handler.c | 4 +
> lib/tests/igt_fork.c | 4 +
> lib/tests/igt_tests_common.h | 9 ++
> runner/executor.c | 14 +++
> tests/core_auth.c | 4 +
> tests/drm_import_export.c | 4 +
> tests/dumb_buffer.c | 5 ++
> tests/i915/gem_close_race.c | 6 ++
> tests/i915/gem_concurrent_all.c | 5 ++
> tests/i915/gem_create.c | 4 +
> tests/i915/gem_ctx_exec.c | 4 +
> tests/i915/gem_ctx_persistence.c | 4 +
> tests/i915/gem_ctx_shared.c | 4 +
> tests/i915/gem_exec_fence.c | 4 +
> tests/i915/gem_exec_latency.c | 4 +
> tests/i915/gem_lmem_swapping.c | 4 +
> tests/i915/gem_madvise.c | 4 +
> tests/i915/gem_mmap_gtt.c | 14 +++
> tests/i915/gem_mmap_offset.c | 14 +++
> tests/i915/gem_shrink.c | 4 +
> tests/i915/gem_wait.c | 4 +
> tests/i915/i915_hangman.c | 4 +
> tests/i915/i915_module_load.c | 2 +
> tests/i915/i915_pm_backlight.c | 4 +
> tests/i915/i915_pm_rpm.c | 13 +++
> tests/i915/sysfs_heartbeat_interval.c | 4 +
> tests/kms_content_protection.c | 2 +
> tests/kms_cursor_legacy.c | 4 +
> tests/kms_flip.c | 4 +
> tests/kms_sysfs_edid_timing.c | 4 +
> tests/sw_sync.c | 3 +
> tests/syncobj_timeline.c | 4 +
> tests/syncobj_wait.c | 4 +
> tests/tools_test.c | 5 ++
> tests/vc4_purgeable_bo.c | 4 +
> tests/vc4_wait_bo.c | 4 +
> tests/vc4_wait_seqno.c | 4 +
> tools/intel_gvtg_test.c | 3 +
> 68 files changed, 552 insertions(+), 6 deletions(-)
>
> diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
> index e6973991..084c8e65 100644
> --- a/benchmarks/gem_exec_tracer.c
> +++ b/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/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
> index 035ee934..be92ff0f 100644
> --- a/benchmarks/gem_syslatency.c
> +++ b/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/include/linux-uapi/sync_file.h
> b/include/linux-uapi/sync_file.h
> index b4f2db00..0f1fb720 100644
> --- a/include/linux-uapi/sync_file.h
> +++ b/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/lib/i915/gem_engine_topology.c
> b/lib/i915/gem_engine_topology.c
> index ca3333c2..9d574de5 100644
> --- a/lib/i915/gem_engine_topology.c
> +++ b/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/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
> index aa9ac6f3..7bd6f22b 100644
> --- a/lib/i915/gem_mman.c
> +++ b/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/lib/i915/intel_memory_region.c
> b/lib/i915/intel_memory_region.c
> index 93a18982..88b2667b 100644
> --- a/lib/i915/intel_memory_region.c
> +++ b/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/lib/i915/perf.c b/lib/i915/perf.c
> index d88835ff..beda6b8a 100644
> --- a/lib/i915/perf.c
> +++ b/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/lib/igt_audio.c b/lib/igt_audio.c
> index e0b1bafe..201a39c6 100644
> --- a/lib/igt_audio.c
> +++ b/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/lib/igt_aux.c b/lib/igt_aux.c
> index edb53425..e6b2bd7e 100644
> --- a/lib/igt_aux.c
> +++ b/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/lib/igt_aux.h b/lib/igt_aux.h
> index c8d487b6..912f36c1 100644
> --- a/lib/igt_aux.h
> +++ b/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/lib/igt_core.c b/lib/igt_core.c
> index e7425326..23f703f3 100644
> --- a/lib/igt_core.c
> +++ b/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 print_usage(const char *help_str, bool
> output_on_stderr)
>
> 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/lib/igt_core.h b/lib/igt_core.h
> index aa98e8ed..7869f722 100644
> --- a/lib/igt_core.h
> +++ b/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/lib/igt_debugfs.c b/lib/igt_debugfs.c
> index a56688a5..b7e37851 100644
> --- a/lib/igt_debugfs.c
> +++ b/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>
> @@ -43,6 +45,10 @@
> #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
> * @short_description: Support code for debugfs features
> diff --git a/lib/igt_device.c b/lib/igt_device.c
> index fddfba72..49b77122 100644
> --- a/lib/igt_device.c
> +++ b/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/lib/igt_device_scan.c b/lib/igt_device_scan.c
> index eb6b45b8..6a921d52 100644
> --- a/lib/igt_device_scan.c
> +++ b/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/lib/igt_eld.c b/lib/igt_eld.c
> index ef6625df..e05ad6de 100644
> --- a/lib/igt_eld.c
> +++ b/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/lib/igt_frame.c b/lib/igt_frame.c
> index 45523a79..ab74e678 100644
> --- a/lib/igt_frame.c
> +++ b/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/lib/igt_kmod.c b/lib/igt_kmod.c
> index bcf7dfeb..12a22a95 100644
> --- a/lib/igt_kmod.c
> +++ b/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/lib/igt_kmod.h b/lib/igt_kmod.h
> index f98dd29f..6596092b 100644
> --- a/lib/igt_kmod.h
> +++ b/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/lib/igt_kms.c b/lib/igt_kms.c
> index 1ba3bd2a..f0208c10 100644
> --- a/lib/igt_kms.c
> +++ b/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/lib/igt_os.c b/lib/igt_os.c
> index bdd5d933..ae426e3a 100644
> --- a/lib/igt_os.c
> +++ b/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/lib/igt_perf.c b/lib/igt_perf.c
> index b743859f..90edbbd0 100644
> --- a/lib/igt_perf.c
> +++ b/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, int group)
> 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)
> +{
> + return strerror(ENOSYS);
> +}
> +
> +uint64_t
> +i915_perf_type_id(int i915)
> +{
> + return -ENOSYS;
> +}
> +
> +int
> +perf_igfx_open(uint64_t config)
> +{
> + return -ENOSYS;
> +}
> +
> +int
> +perf_igfx_open_group(uint64_t config, int group)
> +{
> + return -ENOSYS;
> +}
> +
> +int
> +perf_i915_open(int i915, uint64_t config)
> +{
> + return -ENOSYS;
> +}
> +
> +int
> +perf_i915_open_group(int i915, uint64_t config, int group)
> +{
> + return -ENOSYS;
> +}
> +#endif /* __linux__ */
> diff --git a/lib/igt_perf.h b/lib/igt_perf.h
> index a8328c70..0cd91386 100644
> --- a/lib/igt_perf.h
> +++ b/lib/igt_perf.h
> @@ -27,10 +27,13 @@
>
> #include <stdint.h>
>
> +#ifdef __linux__
> #include <linux/perf_event.h>
> +#endif
>
> #include "igt_gt.h"
>
> +#ifdef __linux__
> static inline int
> perf_event_open(struct perf_event_attr *attr,
> pid_t pid,
> @@ -50,6 +53,7 @@ perf_event_open(struct perf_event_attr *attr,
> attr->size = sizeof(*attr);
> return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);
> }
> +#endif /* __linux__ */
>
> uint64_t igt_perf_type_id(const char *device);
> int igt_perf_open(uint64_t type, uint64_t config);
> diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> index 99251b40..a6036e03 100644
> --- a/lib/igt_pm.c
> +++ b/lib/igt_pm.c
> @@ -33,7 +33,9 @@
> #include <string.h>
> #include <unistd.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <sys/sysmacros.h>
> +#endif
> #include <sys/types.h>
> #include <dirent.h>
>
> diff --git a/lib/igt_syncobj.c b/lib/igt_syncobj.c
> index a24ed10b..eb302986 100644
> --- a/lib/igt_syncobj.c
> +++ b/lib/igt_syncobj.c
> @@ -27,6 +27,10 @@
> #include "igt.h"
> #include "igt_syncobj.h"
>
> +#ifdef __FreeBSD__
> +#define ETIME ETIMEDOUT
> +#endif
> +
> /**
> * SECTION:igt_syncobj
> * @short_description: Library with syncobj helpers
> diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
> index 9c307694..a913be4c 100644
> --- a/lib/igt_sysfs.c
> +++ b/lib/igt_sysfs.c
> @@ -24,7 +24,9 @@
>
> #include <inttypes.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <sys/sysmacros.h>
> +#endif
> #include <sys/mount.h>
> #include <errno.h>
> #include <stdarg.h>
> diff --git a/lib/igt_vgem.c b/lib/igt_vgem.c
> index 7f933b23..9483b896 100644
> --- a/lib/igt_vgem.c
> +++ b/lib/igt_vgem.c
> @@ -30,6 +30,11 @@
> #include "igt_core.h"
> #include "ioctl_wrappers.h"
>
> +#ifdef __FreeBSD__
> +#define mmap64(addr, len, prot, flags, fd, offset) \
> + mmap(addr, len, prot, flags, fd, offset)
> +#endif
> +
> /**
> * SECTION:igt_vgem
> * @short_description: VGEM support library
> diff --git a/lib/intel_allocator.c b/lib/intel_allocator.c
> index 717d7fc5..bd840f57 100644
> --- a/lib/intel_allocator.c
> +++ b/lib/intel_allocator.c
> @@ -17,6 +17,10 @@
> #include "intel_allocator.h"
> #include "intel_allocator_msgchannel.h"
>
> +#ifdef __FreeBSD__
> +#define gettid() getpid()
> +#endif
> +
> //#define ALLOCDBG
> #ifdef ALLOCDBG
> #define alloc_info igt_info
> diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
> index ef1b5947..8004c09e 100644
> --- a/lib/intel_batchbuffer.c
> +++ b/lib/intel_batchbuffer.c
> @@ -60,6 +60,11 @@
> #define BCS_SRC_Y (1 << 0)
> #define BCS_DST_Y (1 << 1)
>
> +#ifdef __FreeBSD__
> +/* memory leak */
> +#define tdestroy(root, free_node)
> +#endif
> +
> /**
> * SECTION:intel_batchbuffer
> * @short_description: Batchbuffer and blitter support
> diff --git a/lib/sw_sync.c b/lib/sw_sync.c
> index 6c762c8b..e5a73ffa 100644
> --- a/lib/sw_sync.c
> +++ b/lib/sw_sync.c
> @@ -41,6 +41,10 @@
> #include "drmtest.h"
> #include "ioctl_wrappers.h"
>
> +#ifdef __FreeBSD__
> +#define ETIME ETIMEDOUT
> +#endif
> +
> /**
> * SECTION:sw_sync
> * @short_description: Software sync (fencing) support library
> diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
> index 892a7f14..d2381944 100644
> --- a/lib/tests/igt_exit_handler.c
> +++ b/lib/tests/igt_exit_handler.c
> @@ -125,5 +125,9 @@ int main(int argc, char **argv)
> internal_assert_wexited(status, IGT_EXIT_SKIP);
>
> status = testfunc(SIG);
> +#ifdef __linux__
> internal_assert_wsignaled(status, SIGTERM);
> +#elif defined(__FreeBSD__)
> + internal_assert(status == 0);
> +#endif
> }
> diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
> index d19d0945..4a2d50d4 100644
> --- a/lib/tests/igt_fork.c
> +++ b/lib/tests/igt_fork.c
> @@ -109,7 +109,11 @@ __noreturn static void igt_fork_timeout_leak(void)
> __noreturn static void subtest_leak(void)
> {
> pid_t *children =
> +#ifdef __linux__
> mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
> +#elif defined(__FreeBSD__)
> + mmap(0, 4096, PROT_WRITE | PROT_READ, MAP_SHARED |
> MAP_ANON, -1, 0);
> +#endif
> const int num_children = 4096 / sizeof(*children);
>
> igt_subtest_init(fake_argc, fake_argv);
> diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
> index 058f6265..e8183897 100644
> --- a/lib/tests/igt_tests_common.h
> +++ b/lib/tests/igt_tests_common.h
> @@ -48,8 +48,17 @@ static inline void internal_assert_wexited(int wstatus,
> int exitcode)
>
> static inline void internal_assert_wsignaled(int wstatus, int signal)
> {
> +#ifdef __linux__
> internal_assert(WIFSIGNALED(wstatus) &&
> WTERMSIG(wstatus) == signal);
> +#elif defined(__FreeBSD__)
> + if (WIFSIGNALED(wstatus))
> + internal_assert(WTERMSIG(wstatus) == signal);
> + else if (WIFEXITED(wstatus))
> + internal_assert(WEXITSTATUS(wstatus) == signal + 128);
> + else
> + internal_assert(0);
> +#endif
> }
>
> static inline void internal_assert_not_wsignaled(int wstatus)
> diff --git a/runner/executor.c b/runner/executor.c
> index 964d0063..65e3d2ba 100644
> --- a/runner/executor.c
> +++ b/runner/executor.c
> @@ -2,7 +2,9 @@
> #include <errno.h>
> #include <fcntl.h>
> #include <glib.h>
> +#ifdef __linux__
> #include <linux/watchdog.h>
> +#endif
> #if HAVE_OPING
> #include <oping.h>
> #endif
> @@ -14,7 +16,9 @@
> #include <sys/ioctl.h>
> #include <sys/select.h>
> #include <sys/poll.h>
> +#ifdef __linux__
> #include <sys/signalfd.h>
> +#endif
> #include <sys/stat.h>
> #include <sys/time.h>
> #include <sys/types.h>
> @@ -33,6 +37,16 @@
> #define KMSG_HEADER "[IGT] "
> #define KMSG_WARN 4
>
> +#ifdef __FreeBSD__
> +#include <sys/watchdog.h>
> +struct signalfd_siginfo {
> + uint32_t ssi_signo;
> + uint32_t ssi_pid;
> +};
> +#define WDIOC_KEEPALIVE WDIOCPATPAT
> +#define signalfd(fd, mask, flags) -ENOSYS
> +#endif
> +
> static struct {
> int *fds;
> size_t num_dogs;
> diff --git a/tests/core_auth.c b/tests/core_auth.c
> index c9ad3fb9..fdd46e92 100644
> --- a/tests/core_auth.c
> +++ b/tests/core_auth.c
> @@ -48,6 +48,10 @@
> # include <pthread.h>
> #endif
>
> +#ifdef __FreeBSD__
> +#define pthread_self() getpid()
> +#endif
> +
> IGT_TEST_DESCRIPTION("Call drmGetMagic() and drmAuthMagic() and see if it
> behaves.");
>
> static bool
> diff --git a/tests/drm_import_export.c b/tests/drm_import_export.c
> index 06245e8b..448d2d70 100644
> --- a/tests/drm_import_export.c
> +++ b/tests/drm_import_export.c
> @@ -45,6 +45,10 @@
> #define DURATION 10
> IGT_TEST_DESCRIPTION("Basic check to verify the behaviour of libdrm bo
> for prime/flink");
>
> +#ifdef __FreeBSD__
> +#define gettid() getpid()
> +#endif
> +
> int fd;
> drm_intel_bufmgr *bufmgr;
> int fd1;
> diff --git a/tests/dumb_buffer.c b/tests/dumb_buffer.c
> index 2c6261bd..e5278a90 100644
> --- a/tests/dumb_buffer.c
> +++ b/tests/dumb_buffer.c
> @@ -50,6 +50,11 @@
> #include "igt_aux.h"
> #include "ioctl_wrappers.h"
>
> +#ifdef __FreeBSD__
> +#undef jmp_buf
> +#define sighandler_t sig_t
> +#endif
> +
> IGT_TEST_DESCRIPTION("This is a test for the generic dumb buffer
> interface.");
>
> static int __dumb_create(int fd, struct drm_mode_create_dumb *create)
> diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
> index 938fde8f..0b7378b2 100644
> --- a/tests/i915/gem_close_race.c
> +++ b/tests/i915/gem_close_race.c
> @@ -53,6 +53,10 @@
> #define BLT_WRITE_ALPHA (1<<21)
> #define BLT_WRITE_RGB (1<<20)
>
> +#ifdef __FreeBSD__
> +#define gettid() getpid()
> +#endif
> +
> IGT_TEST_DESCRIPTION("Test try to race gem_close against workload
> submission.");
>
> static uint32_t devid;
> @@ -61,7 +65,9 @@ static bool has_softpin;
> static uint64_t exec_addr;
> static uint64_t data_addr;
>
> +#ifdef __linux__
> #define sigev_notify_thread_id _sigev_un._tid
> +#endif
>
> static void selfcopy(int fd, uint32_t ctx, uint32_t handle, int loops)
> {
> diff --git a/tests/i915/gem_concurrent_all.c
> b/tests/i915/gem_concurrent_all.c
> index 25b7daf8..e965dadb 100644
> --- a/tests/i915/gem_concurrent_all.c
> +++ b/tests/i915/gem_concurrent_all.c
> @@ -53,6 +53,11 @@
> #include "igt.h"
> #include "igt_vgem.h"
>
> +/* improper substitution */
> +#ifdef __FreeBSD__
> +#define MADV_DONTFORK MADV_NOSYNC
> +#endif
> +
> IGT_TEST_DESCRIPTION("Test of pread/pwrite/mmap behavior when writing to
> active"
> " buffers.");
>
> diff --git a/tests/i915/gem_create.c b/tests/i915/gem_create.c
> index d7d2a017..18d9324e 100644
> --- a/tests/i915/gem_create.c
> +++ b/tests/i915/gem_create.c
> @@ -61,6 +61,10 @@
> #include "i915/gem_mman.h"
> #include "i915_drm.h"
>
> +#ifdef __FreeBSD__
> +#define sighandler_t sig_t
> +#endif
> +
> IGT_TEST_DESCRIPTION("Ensure that basic gem_create and gem_create_ext
> works"
> " and that invalid input combinations are rejected.");
>
> diff --git a/tests/i915/gem_ctx_exec.c b/tests/i915/gem_ctx_exec.c
> index 3d94f01d..3cc7a87c 100644
> --- a/tests/i915/gem_ctx_exec.c
> +++ b/tests/i915/gem_ctx_exec.c
> @@ -48,6 +48,10 @@
> #include "igt_sysfs.h"
> #include "sw_sync.h"
>
> +#ifdef __FreeBSD__
> +#define ETIME ETIMEDOUT
> +#endif
> +
> IGT_TEST_DESCRIPTION("Test context batch buffer execution.");
>
> /* Copied from gem_exec_nop.c */
> diff --git a/tests/i915/gem_ctx_persistence.c
> b/tests/i915/gem_ctx_persistence.c
> index 50196edb..afda4675 100644
> --- a/tests/i915/gem_ctx_persistence.c
> +++ b/tests/i915/gem_ctx_persistence.c
> @@ -50,6 +50,10 @@
> static unsigned long reset_timeout_ms = RESET_TIMEOUT_MS;
> #define NSEC_PER_MSEC (1000 * 1000ull)
>
> +#ifdef __FreeBSD__
> +#define ETIME ETIMEDOUT
> +#endif
> +
> static void cleanup(int i915)
> {
> igt_drop_caches_set(i915,
> diff --git a/tests/i915/gem_ctx_shared.c b/tests/i915/gem_ctx_shared.c
> index eb3b024f..fe1c788b 100644
> --- a/tests/i915/gem_ctx_shared.c
> +++ b/tests/i915/gem_ctx_shared.c
> @@ -54,6 +54,10 @@
> #define MAX_PRIO I915_CONTEXT_MAX_USER_PRIORITY
> #define MIN_PRIO I915_CONTEXT_MIN_USER_PRIORITY
>
> +#ifdef __FreeBSD__
> +#define ETIME ETIMEDOUT
> +#endif
> +
> static int priorities[] = {
> [LO] = MIN_PRIO / 2,
> [HI] = MAX_PRIO / 2,
> diff --git a/tests/i915/gem_exec_fence.c b/tests/i915/gem_exec_fence.c
> index f24bebdb..50b14c87 100644
> --- a/tests/i915/gem_exec_fence.c
> +++ b/tests/i915/gem_exec_fence.c
> @@ -36,6 +36,10 @@
> #include "intel_ctx.h"
> #include "sw_sync.h"
>
> +#ifdef __FreeBSD__
> +#define ETIME ETIMEDOUT
> +#endif
> +
> IGT_TEST_DESCRIPTION("Check that execbuf waits for explicit fences");
>
> #ifndef SYNC_IOC_MERGE
> diff --git a/tests/i915/gem_exec_latency.c b/tests/i915/gem_exec_latency.c
> index fcdf7787..dad9ea27 100644
> --- a/tests/i915/gem_exec_latency.c
> +++ b/tests/i915/gem_exec_latency.c
> @@ -55,6 +55,10 @@
> #define CORK 0x2
> #define PREEMPT 0x4
>
> +#ifdef __FreeBSD__
> +#define SCHED_RESET_ON_FORK 0
> +#endif
> +
> static unsigned int ring_size;
> static double rcs_clock;
> static struct intel_mmio_data mmio_data;
> diff --git a/tests/i915/gem_lmem_swapping.c
> b/tests/i915/gem_lmem_swapping.c
> index cccdb319..34ca455f 100644
> --- a/tests/i915/gem_lmem_swapping.c
> +++ b/tests/i915/gem_lmem_swapping.c
> @@ -25,6 +25,10 @@
> #include "i915/i915_blt.h"
> #include "i915/intel_mocs.h"
>
> +#ifdef __FreeBSD__
> +#define MAP_POPULATE MAP_PREFAULT_READ
> +#endif
> +
> IGT_TEST_DESCRIPTION("Exercise local memory swapping.");
>
> #define __round_mask(x, y) ((__typeof__(x))((y) - 1))
> diff --git a/tests/i915/gem_madvise.c b/tests/i915/gem_madvise.c
> index 2502d84c..4c6cdbc4 100644
> --- a/tests/i915/gem_madvise.c
> +++ b/tests/i915/gem_madvise.c
> @@ -39,6 +39,10 @@
> #include "drm.h"
> #include "i915/gem_create.h"
>
> +#ifdef __FreeBSD__
> +#define sighandler_t sig_t
> +#endif
> +
> IGT_TEST_DESCRIPTION("Checks that the kernel reports EFAULT when trying
> to use"
> " purged bo.");
>
> diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
> index e39b9047..8daa6248 100644
> --- a/tests/i915/gem_mmap_gtt.c
> +++ b/tests/i915/gem_mmap_gtt.c
> @@ -54,6 +54,16 @@
>
> #define abs(x) ((x) >= 0 ? (x) : -(x))
>
> +#ifdef __FreeBSD__
> +#define mmap64(addr, len, prot, flags, fd, offset) \
> + mmap(addr, len, prot, flags, fd, offset)
> +#define PTRACE_TRACEME PT_TRACE_ME
> +#define PTRACE_ATTACH PT_ATTACH
> +#define PTRACE_PEEKDATA PT_READ_D
> +#define PTRACE_POKEDATA PT_WRITE_D
> +#define PTRACE_DETACH PT_DETACH
> +#endif
> +
> IGT_TEST_DESCRIPTION("Ensure that all operations around MMAP_GTT ioctl
> works.");
>
> static int OBJECT_SIZE = 16*1024*1024;
> @@ -566,7 +576,11 @@ test_ptrace(int fd)
> for (int i = 0; i < sz / sizeof(long); i++) {
> long ret;
>
> +#ifdef __linux__
> ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i);
> +#elif defined(__FreeBSD__)
> + ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i, 0);
> +#endif
> igt_assert_eq_u64(ret, CC);
> cpy[i] = ret;
>
> diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
> index 5e6b19eb..21bcdddd 100644
> --- a/tests/i915/gem_mmap_offset.c
> +++ b/tests/i915/gem_mmap_offset.c
> @@ -38,6 +38,16 @@
> #include "igt.h"
> #include "igt_x86.h"
>
> +#ifdef __FreeBSD__
> +#define mmap64(addr, len, prot, flags, fd, offset) \
> + mmap(addr, len, prot, flags, fd, offset)
> +#define PTRACE_TRACEME PT_TRACE_ME
> +#define PTRACE_ATTACH PT_ATTACH
> +#define PTRACE_PEEKDATA PT_READ_D
> +#define PTRACE_POKEDATA PT_WRITE_D
> +#define PTRACE_DETACH PT_DETACH
> +#endif
> +
> IGT_TEST_DESCRIPTION("Basic MMAP_OFFSET IOCTL tests for mem regions\n");
>
> static int mmap_offset_ioctl(int i915, struct drm_i915_gem_mmap_offset
> *arg)
> @@ -370,7 +380,11 @@ static void test_ptrace(int i915)
> for (int i = 0; i < SZ / sizeof(long); i++) {
> long ret;
>
> +#ifdef __linux__
> ret = ptrace(PTRACE_PEEKDATA, pid, ptr +
> i);
> +#elif defined(__FreeBSD__)
> + ret = ptrace(PTRACE_PEEKDATA, pid, ptr +
> i, 0);
> +#endif
> igt_assert_eq_u64(ret, CC);
> cpy[i] = ret;
>
> diff --git a/tests/i915/gem_shrink.c b/tests/i915/gem_shrink.c
> index 49df35c2..e9dd49cf 100644
> --- a/tests/i915/gem_shrink.c
> +++ b/tests/i915/gem_shrink.c
> @@ -38,6 +38,10 @@
> #define MADV_FREE 8
> #endif
>
> +#ifdef __FreeBSD__
> +#define MAP_POPULATE MAP_PREFAULT_READ
> +#endif
> +
> static void get_pages(int fd, uint64_t alloc)
> {
> uint32_t handle = gem_create(fd, alloc);
> diff --git a/tests/i915/gem_wait.c b/tests/i915/gem_wait.c
> index 230304aa..9655fb09 100644
> --- a/tests/i915/gem_wait.c
> +++ b/tests/i915/gem_wait.c
> @@ -32,6 +32,10 @@
> #include "igt.h"
> #include "igt_vgem.h"
>
> +#ifdef __FreeBSD__
> +#define ETIME ETIMEDOUT
> +#endif
> +
> IGT_TEST_DESCRIPTION("Tests the GEM_WAIT ioctl");
>
> static int __gem_wait(int fd, struct drm_i915_gem_wait *w)
> diff --git a/tests/i915/i915_hangman.c b/tests/i915/i915_hangman.c
> index c7d69fdd..c0bde6be 100644
> --- a/tests/i915/i915_hangman.c
> +++ b/tests/i915/i915_hangman.c
> @@ -50,6 +50,10 @@ static int sysfs = -1;
>
> #define OFFSET_ALIVE 10
>
> +#ifdef __FreeBSD__
> +#define ETIME ETIMEDOUT
> +#endif
> +
> IGT_TEST_DESCRIPTION("Tests for hang detection and recovery");
>
> static void check_alive(void)
> diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c
> index 4c72157c..9bec4c18 100644
> --- a/tests/i915/i915_module_load.c
> +++ b/tests/i915/i915_module_load.c
> @@ -23,7 +23,9 @@
> #include "igt.h"
> #include <dirent.h>
> #include <sys/utsname.h>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#endif
> #include <signal.h>
> #include <libgen.h>
> #include <signal.h>
> diff --git a/tests/i915/i915_pm_backlight.c
> b/tests/i915/i915_pm_backlight.c
> index cafae7f7..c520cf20 100644
> --- a/tests/i915/i915_pm_backlight.c
> +++ b/tests/i915/i915_pm_backlight.c
> @@ -46,6 +46,10 @@ struct context {
> #define FADESTEPS 10
> #define FADESPEED 100 /* milliseconds between steps */
>
> +#ifdef __FreeBSD__
> +#include <libgen.h>
> +#endif
> +
> IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
>
> static int backlight_read(int *result, const char *fname)
> diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
> index e95875dc..6a30ecf6 100644
> --- a/tests/i915/i915_pm_rpm.c
> +++ b/tests/i915/i915_pm_rpm.c
> @@ -40,8 +40,10 @@
> #include <sys/mman.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> +#ifdef __linux__
> #include <linux/i2c.h>
> #include <linux/i2c-dev.h>
> +#endif
>
> #include <drm.h>
>
> @@ -54,6 +56,17 @@
> #include "igt_device.h"
> #include "igt_edid.h"
>
> +#ifdef __FreeBSD__
> +#include <limits.h>
> +#include <dev/iicbus/iic.h>
> +
> +#define I2C_RDWR I2CRDWR
> +#define I2C_M_RD IIC_M_RD
> +#define i2c_msg iic_msg
> +#define i2c_rdwr_ioctl_data iic_rdwr_data
> +#define addr slave
> +#endif
> +
> #define MSR_PC8_RES 0x630
> #define MSR_PC9_RES 0x631
> #define MSR_PC10_RES 0x632
> diff --git a/tests/i915/sysfs_heartbeat_interval.c
> b/tests/i915/sysfs_heartbeat_interval.c
> index 8cebf627..cb1f37f8 100644
> --- a/tests/i915/sysfs_heartbeat_interval.c
> +++ b/tests/i915/sysfs_heartbeat_interval.c
> @@ -42,6 +42,10 @@
> #include "igt_sysfs.h"
> #include "sw_sync.h"
>
> +#ifdef __FreeBSD__
> +#define sighandler_t sig_t
> +#endif
> +
> #define ATTR "heartbeat_interval_ms"
> #define RESET_TIMEOUT 50 /* milliseconds, at least one jiffie for kworker
> */
>
> diff --git a/tests/kms_content_protection.c
> b/tests/kms_content_protection.c
> index 3041f1cd..e0e5af78 100644
> --- a/tests/kms_content_protection.c
> +++ b/tests/kms_content_protection.c
> @@ -24,7 +24,9 @@
>
> #include <poll.h>
> #include <fcntl.h>
> +#ifdef __linux__
> #include <sys/epoll.h>
> +#endif
> #include <sys/stat.h>
> #include <libudev.h>
> #include "igt.h"
> diff --git a/tests/kms_cursor_legacy.c b/tests/kms_cursor_legacy.c
> index 1b697667..67a470b6 100644
> --- a/tests/kms_cursor_legacy.c
> +++ b/tests/kms_cursor_legacy.c
> @@ -47,6 +47,10 @@
>
> #define PAGE_SIZE 4096
>
> +#ifdef __FreeBSD__
> +#define SCHED_IDLE SCHED_OTHER
> +#endif
> +
> IGT_TEST_DESCRIPTION("Stress legacy cursor ioctl");
>
> igt_pipe_crc_t *pipe_crc;
> diff --git a/tests/kms_flip.c b/tests/kms_flip.c
> index 0567edea..1127e418 100755
> --- a/tests/kms_flip.c
> +++ b/tests/kms_flip.c
> @@ -45,6 +45,10 @@
> #include "i915/gem_create.h"
> #include "igt_stats.h"
>
> +#ifdef __FreeBSD__
> +#include <sys/consio.h>
> +#endif
> +
> #define TEST_DPMS (1 << 0)
>
> #define TEST_PAN (1 << 3)
> diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
> index 77521108..cd980c6a 100644
> --- a/tests/kms_sysfs_edid_timing.c
> +++ b/tests/kms_sysfs_edid_timing.c
> @@ -26,6 +26,10 @@
> #include <fcntl.h>
> #include <sys/stat.h>
>
> +#ifdef __FreeBSD__
> +#include <limits.h>
> +#endif
> +
> #define THRESHOLD_PER_CONNECTOR 150
> #define THRESHOLD_PER_CONNECTOR_MEAN 140
> #define THRESHOLD_ALL_CONNECTORS_MEAN 100
> diff --git a/tests/sw_sync.c b/tests/sw_sync.c
> index cbd773fc..1290a284 100644
> --- a/tests/sw_sync.c
> +++ b/tests/sw_sync.c
> @@ -38,6 +38,9 @@
>
> #include "sw_sync.h"
>
> +#ifdef __FreeBSD__
> +#define ETIME ETIMEDOUT
> +#endif
>
> IGT_TEST_DESCRIPTION("Test SW Sync Framework");
>
> diff --git a/tests/syncobj_timeline.c b/tests/syncobj_timeline.c
> index 20375cdd..795fd3fb 100644
> --- a/tests/syncobj_timeline.c
> +++ b/tests/syncobj_timeline.c
> @@ -31,6 +31,10 @@
> #include <signal.h>
> #include "drm.h"
>
> +#ifdef __FreeBSD__
> +#define ETIME ETIMEDOUT
> +#endif
> +
> IGT_TEST_DESCRIPTION("Tests for the drm timeline sync object API");
>
> /* One tenth of a second */
> diff --git a/tests/syncobj_wait.c b/tests/syncobj_wait.c
> index 669d0adf..4f31fb76 100644
> --- a/tests/syncobj_wait.c
> +++ b/tests/syncobj_wait.c
> @@ -31,6 +31,10 @@
> #include <signal.h>
> #include "drm.h"
>
> +#ifdef __FreeBSD__
> +#define ETIME ETIMEDOUT
> +#endif
> +
> IGT_TEST_DESCRIPTION("Tests for the drm sync object wait API");
>
> /* One tenth of a second */
> diff --git a/tests/tools_test.c b/tests/tools_test.c
> index 237f0433..6652927a 100644
> --- a/tests/tools_test.c
> +++ b/tests/tools_test.c
> @@ -28,7 +28,12 @@
> #include <fcntl.h>
> #include <libgen.h>
> #include <unistd.h>
> +#ifdef __linux__
> #include <linux/limits.h>
> +#elif defined(__FreeBSD__)
> +#include <limits.h>
> +#define get_current_dir_name() getwd(NULL)
> +#endif
>
> #define TOOLS "../tools/"
>
> diff --git a/tests/vc4_purgeable_bo.c b/tests/vc4_purgeable_bo.c
> index d9f7547f..5aa734b4 100644
> --- a/tests/vc4_purgeable_bo.c
> +++ b/tests/vc4_purgeable_bo.c
> @@ -35,6 +35,10 @@
> #include <sys/ioctl.h>
> #include "vc4_drm.h"
>
> +#ifdef __FreeBSD__
> +#undef jmp_buf
> +#endif
> +
> struct igt_vc4_bo {
> struct igt_list_head node;
> int handle;
> diff --git a/tests/vc4_wait_bo.c b/tests/vc4_wait_bo.c
> index 65a085a3..2c3c9da8 100644
> --- a/tests/vc4_wait_bo.c
> +++ b/tests/vc4_wait_bo.c
> @@ -34,6 +34,10 @@
> #include <sys/ioctl.h>
> #include "vc4_drm.h"
>
> +#ifdef __FreeBSD__
> +#define ETIME ETIMEDOUT
> +#endif
> +
> static void
> test_used_bo(int fd, uint64_t timeout)
> {
> diff --git a/tests/vc4_wait_seqno.c b/tests/vc4_wait_seqno.c
> index bcc263cb..c04c8d78 100644
> --- a/tests/vc4_wait_seqno.c
> +++ b/tests/vc4_wait_seqno.c
> @@ -33,6 +33,10 @@
> #include <sys/ioctl.h>
> #include "vc4_drm.h"
>
> +#ifdef __FreeBSD__
> +#define ETIME ETIMEDOUT
> +#endif
> +
> igt_main
> {
> int fd;
> diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c
> index ad5ee6a6..2f0c94f0 100644
> --- a/tools/intel_gvtg_test.c
> +++ b/tools/intel_gvtg_test.c
> @@ -44,6 +44,9 @@
> #include <sys/ioctl.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> +#ifdef __FreeBSD__
> +#include <sys/wait.h>
> +#endif
> #include <string.h>
> #include <stdlib.h>
> #include <signal.h>
> --
> 2.37.2
>
>
[-- Attachment #2: Type: text/html, Size: 53090 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility
@ 2022-09-02 14:14 Jake Freeland
2022-09-02 14:50 ` Jake Freeland
0 siblings, 1 reply; 20+ messages in thread
From: Jake Freeland @ 2022-09-02 14:14 UTC (permalink / raw)
To: igt-dev; +Cc: Jake Freeland
Signed-off-by: Jake Freeland <jfree@freebsd.org>
---
benchmarks/gem_exec_tracer.c | 4 +
benchmarks/gem_syslatency.c | 9 ++
include/linux-uapi/sync_file.h | 8 ++
lib/i915/gem_engine_topology.c | 4 +
lib/i915/gem_mman.c | 5 ++
lib/i915/intel_memory_region.c | 4 +
lib/i915/perf.c | 2 +
lib/igt_audio.c | 4 +
lib/igt_aux.c | 44 ++++++++++
lib/igt_aux.h | 6 +-
lib/igt_core.c | 16 +++-
lib/igt_core.h | 6 ++
lib/igt_debugfs.c | 6 ++
lib/igt_device.c | 2 +
lib/igt_device_scan.c | 4 +
lib/igt_eld.c | 4 +
lib/igt_frame.c | 4 +
lib/igt_kmod.c | 118 ++++++++++++++++++++++++++
lib/igt_kmod.h | 2 +
lib/igt_kms.c | 4 +
lib/igt_os.c | 19 +++++
lib/igt_perf.c | 58 +++++++++++++
lib/igt_perf.h | 4 +
lib/igt_pm.c | 2 +
lib/igt_syncobj.c | 4 +
lib/igt_sysfs.c | 2 +
lib/igt_vgem.c | 5 ++
lib/intel_allocator.c | 4 +
lib/intel_batchbuffer.c | 5 ++
lib/sw_sync.c | 4 +
lib/tests/igt_exit_handler.c | 4 +
lib/tests/igt_fork.c | 4 +
lib/tests/igt_tests_common.h | 9 ++
runner/executor.c | 14 +++
tests/core_auth.c | 4 +
tests/drm_import_export.c | 4 +
tests/dumb_buffer.c | 5 ++
tests/i915/gem_close_race.c | 6 ++
tests/i915/gem_concurrent_all.c | 5 ++
tests/i915/gem_create.c | 4 +
tests/i915/gem_ctx_exec.c | 4 +
tests/i915/gem_ctx_persistence.c | 4 +
tests/i915/gem_ctx_shared.c | 4 +
tests/i915/gem_exec_fence.c | 4 +
tests/i915/gem_exec_latency.c | 4 +
tests/i915/gem_lmem_swapping.c | 4 +
tests/i915/gem_madvise.c | 4 +
tests/i915/gem_mmap_gtt.c | 14 +++
tests/i915/gem_mmap_offset.c | 14 +++
tests/i915/gem_shrink.c | 4 +
tests/i915/gem_wait.c | 4 +
tests/i915/i915_hangman.c | 4 +
tests/i915/i915_module_load.c | 2 +
tests/i915/i915_pm_backlight.c | 4 +
tests/i915/i915_pm_rpm.c | 13 +++
tests/i915/sysfs_heartbeat_interval.c | 4 +
tests/kms_content_protection.c | 2 +
tests/kms_cursor_legacy.c | 4 +
tests/kms_flip.c | 4 +
tests/kms_sysfs_edid_timing.c | 4 +
tests/sw_sync.c | 3 +
tests/syncobj_timeline.c | 4 +
tests/syncobj_wait.c | 4 +
tests/tools_test.c | 5 ++
tests/vc4_purgeable_bo.c | 4 +
tests/vc4_wait_bo.c | 4 +
tests/vc4_wait_seqno.c | 4 +
tools/intel_gvtg_test.c | 3 +
68 files changed, 552 insertions(+), 6 deletions(-)
diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
index e6973991..084c8e65 100644
--- a/benchmarks/gem_exec_tracer.c
+++ b/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/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
index 035ee934..be92ff0f 100644
--- a/benchmarks/gem_syslatency.c
+++ b/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/include/linux-uapi/sync_file.h b/include/linux-uapi/sync_file.h
index b4f2db00..0f1fb720 100644
--- a/include/linux-uapi/sync_file.h
+++ b/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/lib/i915/gem_engine_topology.c b/lib/i915/gem_engine_topology.c
index ca3333c2..9d574de5 100644
--- a/lib/i915/gem_engine_topology.c
+++ b/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/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
index aa9ac6f3..7bd6f22b 100644
--- a/lib/i915/gem_mman.c
+++ b/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/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
index 93a18982..88b2667b 100644
--- a/lib/i915/intel_memory_region.c
+++ b/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/lib/i915/perf.c b/lib/i915/perf.c
index d88835ff..beda6b8a 100644
--- a/lib/i915/perf.c
+++ b/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/lib/igt_audio.c b/lib/igt_audio.c
index e0b1bafe..201a39c6 100644
--- a/lib/igt_audio.c
+++ b/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/lib/igt_aux.c b/lib/igt_aux.c
index edb53425..e6b2bd7e 100644
--- a/lib/igt_aux.c
+++ b/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/lib/igt_aux.h b/lib/igt_aux.h
index c8d487b6..912f36c1 100644
--- a/lib/igt_aux.h
+++ b/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/lib/igt_core.c b/lib/igt_core.c
index e7425326..23f703f3 100644
--- a/lib/igt_core.c
+++ b/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 print_usage(const char *help_str, bool output_on_stderr)
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/lib/igt_core.h b/lib/igt_core.h
index aa98e8ed..7869f722 100644
--- a/lib/igt_core.h
+++ b/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/lib/igt_debugfs.c b/lib/igt_debugfs.c
index a56688a5..b7e37851 100644
--- a/lib/igt_debugfs.c
+++ b/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>
@@ -43,6 +45,10 @@
#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
* @short_description: Support code for debugfs features
diff --git a/lib/igt_device.c b/lib/igt_device.c
index fddfba72..49b77122 100644
--- a/lib/igt_device.c
+++ b/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/lib/igt_device_scan.c b/lib/igt_device_scan.c
index eb6b45b8..6a921d52 100644
--- a/lib/igt_device_scan.c
+++ b/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/lib/igt_eld.c b/lib/igt_eld.c
index ef6625df..e05ad6de 100644
--- a/lib/igt_eld.c
+++ b/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/lib/igt_frame.c b/lib/igt_frame.c
index 45523a79..ab74e678 100644
--- a/lib/igt_frame.c
+++ b/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/lib/igt_kmod.c b/lib/igt_kmod.c
index bcf7dfeb..12a22a95 100644
--- a/lib/igt_kmod.c
+++ b/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/lib/igt_kmod.h b/lib/igt_kmod.h
index f98dd29f..6596092b 100644
--- a/lib/igt_kmod.h
+++ b/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/lib/igt_kms.c b/lib/igt_kms.c
index 1ba3bd2a..f0208c10 100644
--- a/lib/igt_kms.c
+++ b/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/lib/igt_os.c b/lib/igt_os.c
index bdd5d933..ae426e3a 100644
--- a/lib/igt_os.c
+++ b/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/lib/igt_perf.c b/lib/igt_perf.c
index b743859f..90edbbd0 100644
--- a/lib/igt_perf.c
+++ b/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, int group)
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)
+{
+ return strerror(ENOSYS);
+}
+
+uint64_t
+i915_perf_type_id(int i915)
+{
+ return -ENOSYS;
+}
+
+int
+perf_igfx_open(uint64_t config)
+{
+ return -ENOSYS;
+}
+
+int
+perf_igfx_open_group(uint64_t config, int group)
+{
+ return -ENOSYS;
+}
+
+int
+perf_i915_open(int i915, uint64_t config)
+{
+ return -ENOSYS;
+}
+
+int
+perf_i915_open_group(int i915, uint64_t config, int group)
+{
+ return -ENOSYS;
+}
+#endif /* __linux__ */
diff --git a/lib/igt_perf.h b/lib/igt_perf.h
index a8328c70..0cd91386 100644
--- a/lib/igt_perf.h
+++ b/lib/igt_perf.h
@@ -27,10 +27,13 @@
#include <stdint.h>
+#ifdef __linux__
#include <linux/perf_event.h>
+#endif
#include "igt_gt.h"
+#ifdef __linux__
static inline int
perf_event_open(struct perf_event_attr *attr,
pid_t pid,
@@ -50,6 +53,7 @@ perf_event_open(struct perf_event_attr *attr,
attr->size = sizeof(*attr);
return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);
}
+#endif /* __linux__ */
uint64_t igt_perf_type_id(const char *device);
int igt_perf_open(uint64_t type, uint64_t config);
diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 99251b40..a6036e03 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,7 +33,9 @@
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysmacros.h>
+#endif
#include <sys/types.h>
#include <dirent.h>
diff --git a/lib/igt_syncobj.c b/lib/igt_syncobj.c
index a24ed10b..eb302986 100644
--- a/lib/igt_syncobj.c
+++ b/lib/igt_syncobj.c
@@ -27,6 +27,10 @@
#include "igt.h"
#include "igt_syncobj.h"
+#ifdef __FreeBSD__
+#define ETIME ETIMEDOUT
+#endif
+
/**
* SECTION:igt_syncobj
* @short_description: Library with syncobj helpers
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 9c307694..a913be4c 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -24,7 +24,9 @@
#include <inttypes.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <sys/sysmacros.h>
+#endif
#include <sys/mount.h>
#include <errno.h>
#include <stdarg.h>
diff --git a/lib/igt_vgem.c b/lib/igt_vgem.c
index 7f933b23..9483b896 100644
--- a/lib/igt_vgem.c
+++ b/lib/igt_vgem.c
@@ -30,6 +30,11 @@
#include "igt_core.h"
#include "ioctl_wrappers.h"
+#ifdef __FreeBSD__
+#define mmap64(addr, len, prot, flags, fd, offset) \
+ mmap(addr, len, prot, flags, fd, offset)
+#endif
+
/**
* SECTION:igt_vgem
* @short_description: VGEM support library
diff --git a/lib/intel_allocator.c b/lib/intel_allocator.c
index 717d7fc5..bd840f57 100644
--- a/lib/intel_allocator.c
+++ b/lib/intel_allocator.c
@@ -17,6 +17,10 @@
#include "intel_allocator.h"
#include "intel_allocator_msgchannel.h"
+#ifdef __FreeBSD__
+#define gettid() getpid()
+#endif
+
//#define ALLOCDBG
#ifdef ALLOCDBG
#define alloc_info igt_info
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index ef1b5947..8004c09e 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -60,6 +60,11 @@
#define BCS_SRC_Y (1 << 0)
#define BCS_DST_Y (1 << 1)
+#ifdef __FreeBSD__
+/* memory leak */
+#define tdestroy(root, free_node)
+#endif
+
/**
* SECTION:intel_batchbuffer
* @short_description: Batchbuffer and blitter support
diff --git a/lib/sw_sync.c b/lib/sw_sync.c
index 6c762c8b..e5a73ffa 100644
--- a/lib/sw_sync.c
+++ b/lib/sw_sync.c
@@ -41,6 +41,10 @@
#include "drmtest.h"
#include "ioctl_wrappers.h"
+#ifdef __FreeBSD__
+#define ETIME ETIMEDOUT
+#endif
+
/**
* SECTION:sw_sync
* @short_description: Software sync (fencing) support library
diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
index 892a7f14..d2381944 100644
--- a/lib/tests/igt_exit_handler.c
+++ b/lib/tests/igt_exit_handler.c
@@ -125,5 +125,9 @@ int main(int argc, char **argv)
internal_assert_wexited(status, IGT_EXIT_SKIP);
status = testfunc(SIG);
+#ifdef __linux__
internal_assert_wsignaled(status, SIGTERM);
+#elif defined(__FreeBSD__)
+ internal_assert(status == 0);
+#endif
}
diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
index d19d0945..4a2d50d4 100644
--- a/lib/tests/igt_fork.c
+++ b/lib/tests/igt_fork.c
@@ -109,7 +109,11 @@ __noreturn static void igt_fork_timeout_leak(void)
__noreturn static void subtest_leak(void)
{
pid_t *children =
+#ifdef __linux__
mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+#elif defined(__FreeBSD__)
+ mmap(0, 4096, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANON, -1, 0);
+#endif
const int num_children = 4096 / sizeof(*children);
igt_subtest_init(fake_argc, fake_argv);
diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
index 058f6265..e8183897 100644
--- a/lib/tests/igt_tests_common.h
+++ b/lib/tests/igt_tests_common.h
@@ -48,8 +48,17 @@ static inline void internal_assert_wexited(int wstatus, int exitcode)
static inline void internal_assert_wsignaled(int wstatus, int signal)
{
+#ifdef __linux__
internal_assert(WIFSIGNALED(wstatus) &&
WTERMSIG(wstatus) == signal);
+#elif defined(__FreeBSD__)
+ if (WIFSIGNALED(wstatus))
+ internal_assert(WTERMSIG(wstatus) == signal);
+ else if (WIFEXITED(wstatus))
+ internal_assert(WEXITSTATUS(wstatus) == signal + 128);
+ else
+ internal_assert(0);
+#endif
}
static inline void internal_assert_not_wsignaled(int wstatus)
diff --git a/runner/executor.c b/runner/executor.c
index 964d0063..65e3d2ba 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -2,7 +2,9 @@
#include <errno.h>
#include <fcntl.h>
#include <glib.h>
+#ifdef __linux__
#include <linux/watchdog.h>
+#endif
#if HAVE_OPING
#include <oping.h>
#endif
@@ -14,7 +16,9 @@
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/poll.h>
+#ifdef __linux__
#include <sys/signalfd.h>
+#endif
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
@@ -33,6 +37,16 @@
#define KMSG_HEADER "[IGT] "
#define KMSG_WARN 4
+#ifdef __FreeBSD__
+#include <sys/watchdog.h>
+struct signalfd_siginfo {
+ uint32_t ssi_signo;
+ uint32_t ssi_pid;
+};
+#define WDIOC_KEEPALIVE WDIOCPATPAT
+#define signalfd(fd, mask, flags) -ENOSYS
+#endif
+
static struct {
int *fds;
size_t num_dogs;
diff --git a/tests/core_auth.c b/tests/core_auth.c
index c9ad3fb9..fdd46e92 100644
--- a/tests/core_auth.c
+++ b/tests/core_auth.c
@@ -48,6 +48,10 @@
# include <pthread.h>
#endif
+#ifdef __FreeBSD__
+#define pthread_self() getpid()
+#endif
+
IGT_TEST_DESCRIPTION("Call drmGetMagic() and drmAuthMagic() and see if it behaves.");
static bool
diff --git a/tests/drm_import_export.c b/tests/drm_import_export.c
index 06245e8b..448d2d70 100644
--- a/tests/drm_import_export.c
+++ b/tests/drm_import_export.c
@@ -45,6 +45,10 @@
#define DURATION 10
IGT_TEST_DESCRIPTION("Basic check to verify the behaviour of libdrm bo for prime/flink");
+#ifdef __FreeBSD__
+#define gettid() getpid()
+#endif
+
int fd;
drm_intel_bufmgr *bufmgr;
int fd1;
diff --git a/tests/dumb_buffer.c b/tests/dumb_buffer.c
index 2c6261bd..e5278a90 100644
--- a/tests/dumb_buffer.c
+++ b/tests/dumb_buffer.c
@@ -50,6 +50,11 @@
#include "igt_aux.h"
#include "ioctl_wrappers.h"
+#ifdef __FreeBSD__
+#undef jmp_buf
+#define sighandler_t sig_t
+#endif
+
IGT_TEST_DESCRIPTION("This is a test for the generic dumb buffer interface.");
static int __dumb_create(int fd, struct drm_mode_create_dumb *create)
diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
index 938fde8f..0b7378b2 100644
--- a/tests/i915/gem_close_race.c
+++ b/tests/i915/gem_close_race.c
@@ -53,6 +53,10 @@
#define BLT_WRITE_ALPHA (1<<21)
#define BLT_WRITE_RGB (1<<20)
+#ifdef __FreeBSD__
+#define gettid() getpid()
+#endif
+
IGT_TEST_DESCRIPTION("Test try to race gem_close against workload submission.");
static uint32_t devid;
@@ -61,7 +65,9 @@ static bool has_softpin;
static uint64_t exec_addr;
static uint64_t data_addr;
+#ifdef __linux__
#define sigev_notify_thread_id _sigev_un._tid
+#endif
static void selfcopy(int fd, uint32_t ctx, uint32_t handle, int loops)
{
diff --git a/tests/i915/gem_concurrent_all.c b/tests/i915/gem_concurrent_all.c
index 25b7daf8..e965dadb 100644
--- a/tests/i915/gem_concurrent_all.c
+++ b/tests/i915/gem_concurrent_all.c
@@ -53,6 +53,11 @@
#include "igt.h"
#include "igt_vgem.h"
+/* improper substitution */
+#ifdef __FreeBSD__
+#define MADV_DONTFORK MADV_NOSYNC
+#endif
+
IGT_TEST_DESCRIPTION("Test of pread/pwrite/mmap behavior when writing to active"
" buffers.");
diff --git a/tests/i915/gem_create.c b/tests/i915/gem_create.c
index d7d2a017..18d9324e 100644
--- a/tests/i915/gem_create.c
+++ b/tests/i915/gem_create.c
@@ -61,6 +61,10 @@
#include "i915/gem_mman.h"
#include "i915_drm.h"
+#ifdef __FreeBSD__
+#define sighandler_t sig_t
+#endif
+
IGT_TEST_DESCRIPTION("Ensure that basic gem_create and gem_create_ext works"
" and that invalid input combinations are rejected.");
diff --git a/tests/i915/gem_ctx_exec.c b/tests/i915/gem_ctx_exec.c
index 3d94f01d..3cc7a87c 100644
--- a/tests/i915/gem_ctx_exec.c
+++ b/tests/i915/gem_ctx_exec.c
@@ -48,6 +48,10 @@
#include "igt_sysfs.h"
#include "sw_sync.h"
+#ifdef __FreeBSD__
+#define ETIME ETIMEDOUT
+#endif
+
IGT_TEST_DESCRIPTION("Test context batch buffer execution.");
/* Copied from gem_exec_nop.c */
diff --git a/tests/i915/gem_ctx_persistence.c b/tests/i915/gem_ctx_persistence.c
index 50196edb..afda4675 100644
--- a/tests/i915/gem_ctx_persistence.c
+++ b/tests/i915/gem_ctx_persistence.c
@@ -50,6 +50,10 @@
static unsigned long reset_timeout_ms = RESET_TIMEOUT_MS;
#define NSEC_PER_MSEC (1000 * 1000ull)
+#ifdef __FreeBSD__
+#define ETIME ETIMEDOUT
+#endif
+
static void cleanup(int i915)
{
igt_drop_caches_set(i915,
diff --git a/tests/i915/gem_ctx_shared.c b/tests/i915/gem_ctx_shared.c
index eb3b024f..fe1c788b 100644
--- a/tests/i915/gem_ctx_shared.c
+++ b/tests/i915/gem_ctx_shared.c
@@ -54,6 +54,10 @@
#define MAX_PRIO I915_CONTEXT_MAX_USER_PRIORITY
#define MIN_PRIO I915_CONTEXT_MIN_USER_PRIORITY
+#ifdef __FreeBSD__
+#define ETIME ETIMEDOUT
+#endif
+
static int priorities[] = {
[LO] = MIN_PRIO / 2,
[HI] = MAX_PRIO / 2,
diff --git a/tests/i915/gem_exec_fence.c b/tests/i915/gem_exec_fence.c
index f24bebdb..50b14c87 100644
--- a/tests/i915/gem_exec_fence.c
+++ b/tests/i915/gem_exec_fence.c
@@ -36,6 +36,10 @@
#include "intel_ctx.h"
#include "sw_sync.h"
+#ifdef __FreeBSD__
+#define ETIME ETIMEDOUT
+#endif
+
IGT_TEST_DESCRIPTION("Check that execbuf waits for explicit fences");
#ifndef SYNC_IOC_MERGE
diff --git a/tests/i915/gem_exec_latency.c b/tests/i915/gem_exec_latency.c
index fcdf7787..dad9ea27 100644
--- a/tests/i915/gem_exec_latency.c
+++ b/tests/i915/gem_exec_latency.c
@@ -55,6 +55,10 @@
#define CORK 0x2
#define PREEMPT 0x4
+#ifdef __FreeBSD__
+#define SCHED_RESET_ON_FORK 0
+#endif
+
static unsigned int ring_size;
static double rcs_clock;
static struct intel_mmio_data mmio_data;
diff --git a/tests/i915/gem_lmem_swapping.c b/tests/i915/gem_lmem_swapping.c
index cccdb319..34ca455f 100644
--- a/tests/i915/gem_lmem_swapping.c
+++ b/tests/i915/gem_lmem_swapping.c
@@ -25,6 +25,10 @@
#include "i915/i915_blt.h"
#include "i915/intel_mocs.h"
+#ifdef __FreeBSD__
+#define MAP_POPULATE MAP_PREFAULT_READ
+#endif
+
IGT_TEST_DESCRIPTION("Exercise local memory swapping.");
#define __round_mask(x, y) ((__typeof__(x))((y) - 1))
diff --git a/tests/i915/gem_madvise.c b/tests/i915/gem_madvise.c
index 2502d84c..4c6cdbc4 100644
--- a/tests/i915/gem_madvise.c
+++ b/tests/i915/gem_madvise.c
@@ -39,6 +39,10 @@
#include "drm.h"
#include "i915/gem_create.h"
+#ifdef __FreeBSD__
+#define sighandler_t sig_t
+#endif
+
IGT_TEST_DESCRIPTION("Checks that the kernel reports EFAULT when trying to use"
" purged bo.");
diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
index e39b9047..8daa6248 100644
--- a/tests/i915/gem_mmap_gtt.c
+++ b/tests/i915/gem_mmap_gtt.c
@@ -54,6 +54,16 @@
#define abs(x) ((x) >= 0 ? (x) : -(x))
+#ifdef __FreeBSD__
+#define mmap64(addr, len, prot, flags, fd, offset) \
+ mmap(addr, len, prot, flags, fd, offset)
+#define PTRACE_TRACEME PT_TRACE_ME
+#define PTRACE_ATTACH PT_ATTACH
+#define PTRACE_PEEKDATA PT_READ_D
+#define PTRACE_POKEDATA PT_WRITE_D
+#define PTRACE_DETACH PT_DETACH
+#endif
+
IGT_TEST_DESCRIPTION("Ensure that all operations around MMAP_GTT ioctl works.");
static int OBJECT_SIZE = 16*1024*1024;
@@ -566,7 +576,11 @@ test_ptrace(int fd)
for (int i = 0; i < sz / sizeof(long); i++) {
long ret;
+#ifdef __linux__
ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i);
+#elif defined(__FreeBSD__)
+ ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i, 0);
+#endif
igt_assert_eq_u64(ret, CC);
cpy[i] = ret;
diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
index 5e6b19eb..21bcdddd 100644
--- a/tests/i915/gem_mmap_offset.c
+++ b/tests/i915/gem_mmap_offset.c
@@ -38,6 +38,16 @@
#include "igt.h"
#include "igt_x86.h"
+#ifdef __FreeBSD__
+#define mmap64(addr, len, prot, flags, fd, offset) \
+ mmap(addr, len, prot, flags, fd, offset)
+#define PTRACE_TRACEME PT_TRACE_ME
+#define PTRACE_ATTACH PT_ATTACH
+#define PTRACE_PEEKDATA PT_READ_D
+#define PTRACE_POKEDATA PT_WRITE_D
+#define PTRACE_DETACH PT_DETACH
+#endif
+
IGT_TEST_DESCRIPTION("Basic MMAP_OFFSET IOCTL tests for mem regions\n");
static int mmap_offset_ioctl(int i915, struct drm_i915_gem_mmap_offset *arg)
@@ -370,7 +380,11 @@ static void test_ptrace(int i915)
for (int i = 0; i < SZ / sizeof(long); i++) {
long ret;
+#ifdef __linux__
ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i);
+#elif defined(__FreeBSD__)
+ ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i, 0);
+#endif
igt_assert_eq_u64(ret, CC);
cpy[i] = ret;
diff --git a/tests/i915/gem_shrink.c b/tests/i915/gem_shrink.c
index 49df35c2..e9dd49cf 100644
--- a/tests/i915/gem_shrink.c
+++ b/tests/i915/gem_shrink.c
@@ -38,6 +38,10 @@
#define MADV_FREE 8
#endif
+#ifdef __FreeBSD__
+#define MAP_POPULATE MAP_PREFAULT_READ
+#endif
+
static void get_pages(int fd, uint64_t alloc)
{
uint32_t handle = gem_create(fd, alloc);
diff --git a/tests/i915/gem_wait.c b/tests/i915/gem_wait.c
index 230304aa..9655fb09 100644
--- a/tests/i915/gem_wait.c
+++ b/tests/i915/gem_wait.c
@@ -32,6 +32,10 @@
#include "igt.h"
#include "igt_vgem.h"
+#ifdef __FreeBSD__
+#define ETIME ETIMEDOUT
+#endif
+
IGT_TEST_DESCRIPTION("Tests the GEM_WAIT ioctl");
static int __gem_wait(int fd, struct drm_i915_gem_wait *w)
diff --git a/tests/i915/i915_hangman.c b/tests/i915/i915_hangman.c
index c7d69fdd..c0bde6be 100644
--- a/tests/i915/i915_hangman.c
+++ b/tests/i915/i915_hangman.c
@@ -50,6 +50,10 @@ static int sysfs = -1;
#define OFFSET_ALIVE 10
+#ifdef __FreeBSD__
+#define ETIME ETIMEDOUT
+#endif
+
IGT_TEST_DESCRIPTION("Tests for hang detection and recovery");
static void check_alive(void)
diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c
index 4c72157c..9bec4c18 100644
--- a/tests/i915/i915_module_load.c
+++ b/tests/i915/i915_module_load.c
@@ -23,7 +23,9 @@
#include "igt.h"
#include <dirent.h>
#include <sys/utsname.h>
+#ifdef __linux__
#include <linux/limits.h>
+#endif
#include <signal.h>
#include <libgen.h>
#include <signal.h>
diff --git a/tests/i915/i915_pm_backlight.c b/tests/i915/i915_pm_backlight.c
index cafae7f7..c520cf20 100644
--- a/tests/i915/i915_pm_backlight.c
+++ b/tests/i915/i915_pm_backlight.c
@@ -46,6 +46,10 @@ struct context {
#define FADESTEPS 10
#define FADESPEED 100 /* milliseconds between steps */
+#ifdef __FreeBSD__
+#include <libgen.h>
+#endif
+
IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
static int backlight_read(int *result, const char *fname)
diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
index e95875dc..6a30ecf6 100644
--- a/tests/i915/i915_pm_rpm.c
+++ b/tests/i915/i915_pm_rpm.c
@@ -40,8 +40,10 @@
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef __linux__
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
+#endif
#include <drm.h>
@@ -54,6 +56,17 @@
#include "igt_device.h"
#include "igt_edid.h"
+#ifdef __FreeBSD__
+#include <limits.h>
+#include <dev/iicbus/iic.h>
+
+#define I2C_RDWR I2CRDWR
+#define I2C_M_RD IIC_M_RD
+#define i2c_msg iic_msg
+#define i2c_rdwr_ioctl_data iic_rdwr_data
+#define addr slave
+#endif
+
#define MSR_PC8_RES 0x630
#define MSR_PC9_RES 0x631
#define MSR_PC10_RES 0x632
diff --git a/tests/i915/sysfs_heartbeat_interval.c b/tests/i915/sysfs_heartbeat_interval.c
index 8cebf627..cb1f37f8 100644
--- a/tests/i915/sysfs_heartbeat_interval.c
+++ b/tests/i915/sysfs_heartbeat_interval.c
@@ -42,6 +42,10 @@
#include "igt_sysfs.h"
#include "sw_sync.h"
+#ifdef __FreeBSD__
+#define sighandler_t sig_t
+#endif
+
#define ATTR "heartbeat_interval_ms"
#define RESET_TIMEOUT 50 /* milliseconds, at least one jiffie for kworker */
diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
index 3041f1cd..e0e5af78 100644
--- a/tests/kms_content_protection.c
+++ b/tests/kms_content_protection.c
@@ -24,7 +24,9 @@
#include <poll.h>
#include <fcntl.h>
+#ifdef __linux__
#include <sys/epoll.h>
+#endif
#include <sys/stat.h>
#include <libudev.h>
#include "igt.h"
diff --git a/tests/kms_cursor_legacy.c b/tests/kms_cursor_legacy.c
index 1b697667..67a470b6 100644
--- a/tests/kms_cursor_legacy.c
+++ b/tests/kms_cursor_legacy.c
@@ -47,6 +47,10 @@
#define PAGE_SIZE 4096
+#ifdef __FreeBSD__
+#define SCHED_IDLE SCHED_OTHER
+#endif
+
IGT_TEST_DESCRIPTION("Stress legacy cursor ioctl");
igt_pipe_crc_t *pipe_crc;
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 0567edea..1127e418 100755
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -45,6 +45,10 @@
#include "i915/gem_create.h"
#include "igt_stats.h"
+#ifdef __FreeBSD__
+#include <sys/consio.h>
+#endif
+
#define TEST_DPMS (1 << 0)
#define TEST_PAN (1 << 3)
diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
index 77521108..cd980c6a 100644
--- a/tests/kms_sysfs_edid_timing.c
+++ b/tests/kms_sysfs_edid_timing.c
@@ -26,6 +26,10 @@
#include <fcntl.h>
#include <sys/stat.h>
+#ifdef __FreeBSD__
+#include <limits.h>
+#endif
+
#define THRESHOLD_PER_CONNECTOR 150
#define THRESHOLD_PER_CONNECTOR_MEAN 140
#define THRESHOLD_ALL_CONNECTORS_MEAN 100
diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index cbd773fc..1290a284 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -38,6 +38,9 @@
#include "sw_sync.h"
+#ifdef __FreeBSD__
+#define ETIME ETIMEDOUT
+#endif
IGT_TEST_DESCRIPTION("Test SW Sync Framework");
diff --git a/tests/syncobj_timeline.c b/tests/syncobj_timeline.c
index 20375cdd..795fd3fb 100644
--- a/tests/syncobj_timeline.c
+++ b/tests/syncobj_timeline.c
@@ -31,6 +31,10 @@
#include <signal.h>
#include "drm.h"
+#ifdef __FreeBSD__
+#define ETIME ETIMEDOUT
+#endif
+
IGT_TEST_DESCRIPTION("Tests for the drm timeline sync object API");
/* One tenth of a second */
diff --git a/tests/syncobj_wait.c b/tests/syncobj_wait.c
index 669d0adf..4f31fb76 100644
--- a/tests/syncobj_wait.c
+++ b/tests/syncobj_wait.c
@@ -31,6 +31,10 @@
#include <signal.h>
#include "drm.h"
+#ifdef __FreeBSD__
+#define ETIME ETIMEDOUT
+#endif
+
IGT_TEST_DESCRIPTION("Tests for the drm sync object wait API");
/* One tenth of a second */
diff --git a/tests/tools_test.c b/tests/tools_test.c
index 237f0433..6652927a 100644
--- a/tests/tools_test.c
+++ b/tests/tools_test.c
@@ -28,7 +28,12 @@
#include <fcntl.h>
#include <libgen.h>
#include <unistd.h>
+#ifdef __linux__
#include <linux/limits.h>
+#elif defined(__FreeBSD__)
+#include <limits.h>
+#define get_current_dir_name() getwd(NULL)
+#endif
#define TOOLS "../tools/"
diff --git a/tests/vc4_purgeable_bo.c b/tests/vc4_purgeable_bo.c
index d9f7547f..5aa734b4 100644
--- a/tests/vc4_purgeable_bo.c
+++ b/tests/vc4_purgeable_bo.c
@@ -35,6 +35,10 @@
#include <sys/ioctl.h>
#include "vc4_drm.h"
+#ifdef __FreeBSD__
+#undef jmp_buf
+#endif
+
struct igt_vc4_bo {
struct igt_list_head node;
int handle;
diff --git a/tests/vc4_wait_bo.c b/tests/vc4_wait_bo.c
index 65a085a3..2c3c9da8 100644
--- a/tests/vc4_wait_bo.c
+++ b/tests/vc4_wait_bo.c
@@ -34,6 +34,10 @@
#include <sys/ioctl.h>
#include "vc4_drm.h"
+#ifdef __FreeBSD__
+#define ETIME ETIMEDOUT
+#endif
+
static void
test_used_bo(int fd, uint64_t timeout)
{
diff --git a/tests/vc4_wait_seqno.c b/tests/vc4_wait_seqno.c
index bcc263cb..c04c8d78 100644
--- a/tests/vc4_wait_seqno.c
+++ b/tests/vc4_wait_seqno.c
@@ -33,6 +33,10 @@
#include <sys/ioctl.h>
#include "vc4_drm.h"
+#ifdef __FreeBSD__
+#define ETIME ETIMEDOUT
+#endif
+
igt_main
{
int fd;
diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c
index ad5ee6a6..2f0c94f0 100644
--- a/tools/intel_gvtg_test.c
+++ b/tools/intel_gvtg_test.c
@@ -44,6 +44,9 @@
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef __FreeBSD__
+#include <sys/wait.h>
+#endif
#include <string.h>
#include <stdlib.h>
#include <signal.h>
--
2.37.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
end of thread, other threads:[~2022-10-06 17:25 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-06 2:23 [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility Jake Freeland
2022-10-06 3:24 ` [igt-dev] ✓ Fi.CI.BAT: success for Introduced partial FreeBSD compatibility (rev8) Patchwork
2022-10-06 7:59 ` [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility Petri Latvala
2022-10-06 15:49 ` Jake Freeland
2022-10-06 12:50 ` Kamil Konieczny
2022-10-06 17:25 ` [igt-dev] ✗ Fi.CI.IGT: failure for Introduced partial FreeBSD compatibility (rev8) Patchwork
-- strict thread matches above, loose matches on Subject: below --
2022-10-06 1:09 [igt-dev] [PATCH i-g-t] Introduced partial FreeBSD compatibility Jake Freeland
2022-09-28 20:21 Jake Freeland
2022-10-04 9:41 ` Petri Latvala
2022-10-06 2:30 ` Jake Freeland
2022-09-28 19:34 Jake Freeland
2022-09-21 4:15 Jake Freeland
2022-09-18 22:00 Jake Freeland
2022-09-11 0:25 Jake Freeland
2022-09-13 9:53 ` Petri Latvala
2022-09-14 20:16 ` Kamil Konieczny
2022-09-18 22:07 ` Jake Freeland
2022-09-02 14:14 Jake Freeland
2022-09-02 14:50 ` Jake Freeland
2022-09-05 9:06 ` Petri Latvala
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.