Introduced partial FreeBSD compatibility
PATCH 1/1 Introduced partial FreeBSD compatibility
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
--- 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
benchmarks/gem_exec_tracer.c +4 -0
@@ -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);
benchmarks/gem_syslatency.c +6 -0
@@ -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;
include/linux-uapi/sync_file.h +5 -0
@@ -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
lib/i915/intel_memory_region.c +4 -0
@@ -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>
lib/i915/perf.c +2 -0
@@ -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>
lib/igt_audio.c +4 -0
@@ -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>
lib/igt_aux.c +2 -0
@@ -52,7 +52,9 @@#include <assert.h> #include <grp.h> +#ifdef __linux__#include <proc/readproc.h> +#endif #include <libudev.h> #include "drmtest.h"
lib/igt_aux.h +2 -4
@@ -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 */
lib/igt_core.c +5 -3
@@ -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 :
lib/igt_core.h +7 -0
@@ -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__)
lib/igt_debugfs.c +2 -0
@@ -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>
lib/igt_device.c +2 -0
@@ -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"
lib/igt_device_scan.c +4 -0
@@ -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>
lib/igt_eld.c +4 -0
@@ -23,6 +23,10 @@* Authors: Simon Ser <[email protected]> */ +#ifdef __FreeBSD__ +#include <limits.h> +#endif +#include "config.h" #include <dirent.h>
lib/igt_frame.c +4 -0
@@ -24,6 +24,10 @@* Paul Kocialkowski <[email protected]> */ +#ifdef __FreeBSD__ +#include <limits.h> +#endif +#include "config.h" #include <fcntl.h>
lib/igt_freebsd.h new file +121 -0
121 lines not on this page · raw message
lib/igt_kmod.h +2 -0
@@ -24,7 +24,9 @@#ifndef IGT_KMOD_H #define IGT_KMOD_H +#ifdef __linux__#include <libkmod.h> +#endif #include "igt_list.h"
lib/igt_kms.c +4 -0
@@ -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>
lib/igt_os.c +19 -0
@@ -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 ;
lib/igt_perf.c +2 -0
@@ -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>
lib/igt_perf.h +4 -0
@@ -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);
lib/igt_pm.c +2 -0
@@ -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>
lib/igt_sysfs.c +2 -0
@@ -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>
lib/tests/igt_exit_handler.c +4 -0
@@ -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 }
lib/tests/igt_fork.c +1 -1
@@ -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);
lib/tests/igt_tests_common.h +9 -0
@@ -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)
runner/executor.c +6 -0
@@ -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;
runner/job_list.c +5 -0
@@ -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>
tests/i915/gem_close_race.c +2 -0
@@ -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) {
tests/i915/gem_mmap_gtt.c +1 -1
@@ -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;
tests/i915/gem_mmap_offset.c +1 -1
@@ -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;
tests/i915/i915_module_load.c +2 -0
@@ -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>
tests/i915/i915_pm_backlight.c +4 -0
@@ -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)
tests/i915/i915_pm_rpm.c +8 -0
@@ -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
tests/kms_content_protection.c +2 -0
@@ -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"
tests/kms_flip.c +4 -0
@@ -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)
tests/kms_sysfs_edid_timing.c +4 -0
@@ -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
tests/tools_test.c +4 -0
@@ -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/"
tools/intel_gvtg_test.c +4 -0
@@ -55,6 +55,10 @@#include <limits.h> #include <dirent.h> +#ifdef __FreeBSD__ +#include <sys/wait.h> +#endif +#define RANDOM (x) (rand() % x)
Signature · 1 line
2.37.3
Patchwork
CI[igt-dev] ✗ Fi.CI.BUILD: failure for Introduced partial FreeBSD compatibility (rev5)
== Series Details ==
== Series Details ==
Series: Introduced partial FreeBSD compatibility (rev5)
URL : https://patchwork.freedesktop.org/series/108081/
State : failure
== Summary ==
Applying: Introduced partial FreeBSD compatibility
Using index info to reconstruct a base tree...
M lib/i915/intel_memory_region.c
M tests/i915/gem_mmap_offset.c
Falling back to patching base and 3-way merge... Auto-merging tests/i915/gem_mmap_offset.c
CONFLICT (content): Merge conflict in tests/i915/gem_mmap_offset.c Auto-merging lib/i915/intel_memory_region.c
Patch failed at 0001 Introduced partial FreeBSD compatibility When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".