@@ -345,6 +345,7 @@ F: package/gpsd/
F: package/gptfdisk/
F: package/hddtemp/
F: package/hdparm/
+F: package/igt-gpu-tools/
F: package/intel-gmmlib/
F: package/intel-mediadriver/
F: package/intel-mediasdk/
@@ -318,6 +318,7 @@ comment "Graphic applications"
source "package/glmark2/Config.in"
source "package/glslsandbox-player/Config.in"
source "package/gnuplot/Config.in"
+ source "package/igt-gpu-tools/Config.in"
source "package/jhead/Config.in"
source "package/kmscube/Config.in"
source "package/libva-utils/Config.in"
new file mode 100644
@@ -0,0 +1,34 @@
+From d5373adea6248c0fe41870d50b24fc4ed36c6490 Mon Sep 17 00:00:00 2001
+From: Bernd Kuhls <bernd@kuhls.net>
+Date: Sat, 21 Oct 2023 16:47:07 +0200
+Subject: [PATCH] build: check that outb is present in io.h
+
+With glibc if io.h exists, inb/outb are always defined.
+However on musl, io.h always exists but it may not define inb/outb.
+
+Thus, igt-gpu-tools builds with musl on non-x86 platforms will fail to
+link. Fix this by checking for both io.h and that outb() is defined.
+
+Upstream: https://lists.freedesktop.org/archives/igt-dev/2023-October/063811.html
+
+Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
+---
+ meson.build | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/meson.build b/meson.build
+index b35a00faa..cee8a7446 100644
+--- a/meson.build
++++ b/meson.build
+@@ -220,7 +220,7 @@ endif
+ if cc.has_header('libgen.h')
+ config.set('HAVE_LIBGEN_H', 1)
+ endif
+-if cc.has_header('sys/io.h')
++if cc.has_header('sys/io.h') and cc.has_function('outb', prefix: '#include <sys/io.h>')
+ config.set('HAVE_SYS_IO_H', 1)
+ endif
+ if cc.links('''
+--
+2.39.2
+
new file mode 100644
@@ -0,0 +1,89 @@
+From fea7a3189a6e42bb625c3742828849d6360f1435 Mon Sep 17 00:00:00 2001
+From: Stefano Ragni <st3r4g@protonmail.com>
+Date: Sun, 22 Oct 2023 11:47:39 +0200
+Subject: [PATCH] Include limits.h to fix build with musl libc
+
+Original patch was added to void-linux:
+https://github.com/void-linux/void-packages/commit/ddfc1f66a0c571b420303c33aed29fd38ace4fc7
+
+Bug report with request to split the original patch into some
+functional changes:
+Link: https://gitlab.freedesktop.org/drm/igt-gpu-tools/-/issues/138
+
+Upstream: https://lists.freedesktop.org/archives/igt-dev/2023-October/063815.html
+
+Signed-off-by: Stefano Ragni <st3r4g@protonmail.com>
+Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
+[Bernd: alphabetically sorted includes, removed includes not needed
+ anymore, backported to v1.28]
+---
+ lib/igt_aux.c | 1 +
+ lib/igt_eld.c | 1 +
+ lib/igt_hwmon.c | 1 +
+ tests/intel/i915_pm_rpm.c | 1 +
+ tests/kms_sysfs_edid_timing.c | 1 +
+ 5 files changed, 5 insertions(+)
+
+diff --git a/lib/igt_aux.c b/lib/igt_aux.c
+index 18edc5ef9..d6aeb876b 100644
+--- a/lib/igt_aux.c
++++ b/lib/igt_aux.c
+@@ -31,6 +31,7 @@
+ #endif
+ #include <stdio.h>
+ #include <fcntl.h>
++#include <limits.h> // PATH_MAX
+ #include <pwd.h>
+ #include <sys/stat.h>
+ #include <sys/ioctl.h>
+diff --git a/lib/igt_eld.c b/lib/igt_eld.c
+index ef6625df1..6cec9abdd 100644
+--- a/lib/igt_eld.c
++++ b/lib/igt_eld.c
+@@ -28,6 +28,7 @@
+ #include <dirent.h>
+ #include <errno.h>
+ #include <glob.h>
++#include <limits.h> // PATH_MAX
+ #include <stdint.h>
+ #include <stdio.h>
+ #include <string.h>
+diff --git a/lib/igt_hwmon.c b/lib/igt_hwmon.c
+index 309019d69..6216a1607 100644
+--- a/lib/igt_hwmon.c
++++ b/lib/igt_hwmon.c
+@@ -2,6 +2,7 @@
+ /*
+ * Copyright © 2022 Intel Corporation
+ */
++#include <limits.h> // PATH_MAX
+ #include <sys/stat.h>
+ #include <sys/sysmacros.h>
+ #include <dirent.h>
+diff --git a/tests/intel/i915_pm_rpm.c b/tests/intel/i915_pm_rpm.c
+index 17413ffe5..bf0ab4ae7 100644
+--- a/tests/intel/i915_pm_rpm.c
++++ b/tests/intel/i915_pm_rpm.c
+@@ -35,6 +35,7 @@
+
+ #include <unistd.h>
+ #include <fcntl.h>
++#include <limits.h> // PATH_MAX
+ #include <dirent.h>
+ #include <sys/ioctl.h>
+ #include <sys/mman.h>
+diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
+index ee47a024e..c371a5e5e 100644
+--- a/tests/kms_sysfs_edid_timing.c
++++ b/tests/kms_sysfs_edid_timing.c
+@@ -24,6 +24,7 @@
+
+ #include <dirent.h>
+ #include <fcntl.h>
++#include <limits.h> // PATH_MAX
+ #include <sys/stat.h>
+ /**
+ * TEST: kms sysfs edid timing
+--
+2.39.2
+
new file mode 100644
@@ -0,0 +1,57 @@
+From 6695ea970627499d6eb5d5db2edead50ebb2511d Mon Sep 17 00:00:00 2001
+From: Bernd Kuhls <bernd@kuhls.net>
+Date: Sun, 22 Oct 2023 11:57:32 +0200
+Subject: [PATCH] lib/igt_aux.h: Fix musl build
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Inspired by https://www.openwall.com/lists/musl/2020/10/28/11
+
+Define sigev_notify_thread_id only when needed, quoting
+https://sourceware.org/bugzilla/show_bug.cgi?id=27417
+Both freebsd and musl actually have this macro defined under <signal.h>
+
+Fixes build error:
+
+../lib/igt_aux.c:191:20: error: ‘struct sigevent’ has no member named ‘_sigev_un’
+ 191 | sev.sigev_notify_thread_id = __igt_sigiter.tid;
+
+../lib/igt_aux.c:1994:12: error: ‘struct sigevent’ has no member named ‘_sigev_un’
+ 1994 | sev.sigev_notify_thread_id = gettid();
+
+Link: https://gitlab.freedesktop.org/drm/igt-gpu-tools/-/issues/138
+
+Upstream: https://lists.freedesktop.org/archives/igt-dev/2023-October/063814.html
+
+Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
+---
+ lib/igt_aux.h | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/lib/igt_aux.h b/lib/igt_aux.h
+index fb76b0313..55f0aa3b5 100644
+--- a/lib/igt_aux.h
++++ b/lib/igt_aux.h
+@@ -29,6 +29,7 @@
+ #define IGT_AUX_H
+
+ #include <inttypes.h>
++#include <signal.h>
+ #include <stdbool.h>
+ #include <stddef.h>
+ #include <sys/time.h>
+@@ -48,7 +49,9 @@
+ # ifndef HAVE_GETTID
+ # define gettid() (pid_t)(syscall(__NR_gettid))
+ # endif
+-# define sigev_notify_thread_id _sigev_un._tid
++# ifndef sigev_notify_thread_id
++# define sigev_notify_thread_id _sigev_un._tid
++# endif
+ #endif
+
+ /* auxialiary igt helpers from igt_aux.c */
+--
+2.39.2
+
new file mode 100644
@@ -0,0 +1,43 @@
+From b47d645b3a1f476688201c23e9ef6fbccc891cec Mon Sep 17 00:00:00 2001
+From: Stefano Ragni <st3r4g@protonmail.com>
+Date: Sun, 22 Oct 2023 12:06:01 +0200
+Subject: [PATCH] lib/igt_x86.c: Fix musl/uclibc build
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Original patch was added to void-linux:
+https://github.com/void-linux/void-packages/commit/ddfc1f66a0c571b420303c33aed29fd38ace4fc7
+
+Fixes build error:
+../lib/igt_x86.c:295:6: error: ‘ifunc’ is not supported on this target
+ 295 | void igt_memcpy_from_wc(void *dst, const void *src, unsigned long len)
+
+Bug report with request to split the original patch into some
+functional changes:
+Link: https://gitlab.freedesktop.org/drm/igt-gpu-tools/-/issues/138
+
+Upstream: https://lists.freedesktop.org/archives/igt-dev/2023-October/063813.html
+
+Signed-off-by: Stefano Ragni <st3r4g@protonmail.com>
+Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
+---
+ lib/igt_x86.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/lib/igt_x86.c b/lib/igt_x86.c
+index 6ac700df0..8c102fd13 100644
+--- a/lib/igt_x86.c
++++ b/lib/igt_x86.c
+@@ -190,7 +190,7 @@ char *igt_x86_features_to_string(unsigned features, char *line)
+ }
+ #endif
+
+-#if defined(__x86_64__) && !defined(__clang__)
++#if defined(__x86_64__) && !defined(__clang__) && defined(__GLIBC__) && !defined(__UCLIBC__)
+ #pragma GCC push_options
+ #pragma GCC target("sse4.1")
+ #pragma GCC diagnostic ignored "-Wpointer-arith"
+--
+2.39.2
+
new file mode 100644
@@ -0,0 +1,46 @@
+From b81a041f3e07a377db7fa1ea79f83ed2d0183b61 Mon Sep 17 00:00:00 2001
+From: Stefano Ragni <st3r4g@protonmail.com>
+Date: Sun, 22 Oct 2023 12:08:54 +0200
+Subject: [PATCH] lib/igt_halffloat.c: Fix musl/uclibc build
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Original patch was added to void-linux:
+https://github.com/void-linux/void-packages/commit/ddfc1f66a0c571b420303c33aed29fd38ace4fc7
+
+Fixes build error:
+../lib/igt_halffloat.c:205:6: error: ‘ifunc’ is not supported on this target
+ 205 | void igt_float_to_half(const float *f, uint16_t *h, unsigned int num)
+
+../lib/igt_halffloat.c:216:6: error: ‘ifunc’ is not supported on this target
+ 216 | void igt_half_to_float(const uint16_t *h, float *f, unsigned int num)
+
+Bug report with request to split the original patch into some
+functional changes:
+Link: https://gitlab.freedesktop.org/drm/igt-gpu-tools/-/issues/138
+
+Upstream: https://lists.freedesktop.org/archives/igt-dev/2023-October/063816.html
+
+Signed-off-by: Stefano Ragni <st3r4g@protonmail.com>
+Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
+---
+ lib/igt_halffloat.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/lib/igt_halffloat.c b/lib/igt_halffloat.c
+index 08ab05fce..5dbe08e01 100644
+--- a/lib/igt_halffloat.c
++++ b/lib/igt_halffloat.c
+@@ -162,7 +162,7 @@ static inline float _half_to_float(uint16_t val)
+ return fi.f;
+ }
+
+-#if defined(__x86_64__) && !defined(__clang__)
++#if defined(__x86_64__) && !defined(__clang__) && defined(__GLIBC__) && !defined(__UCLIBC__)
+ #pragma GCC push_options
+ #pragma GCC target("f16c")
+
+--
+2.39.2
+
new file mode 100644
@@ -0,0 +1,46 @@
+From 5d4df590185ca31ebd1a9ce90922907c15658c17 Mon Sep 17 00:00:00 2001
+From: Mohammed Anas <triallax@tutanota.com>
+Date: Sun, 22 Oct 2023 12:10:23 +0200
+Subject: [PATCH] benchmarks/gem_exec_tracer.c: Fix musl build
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Original patch was added to void-linux:
+https://github.com/void-linux/void-packages/commit/111918317d06598fe1459dbe139923404f3f4b9d
+
+Fixes build error:
+../benchmarks/gem_exec_tracer.c:274:1: error: conflicting types for ‘ioctl’; have ‘int(int, long unsigned int, ...)’
+ 274 | ioctl(int fd, unsigned long request, ...)
+
+Bug report with request to split the original patch into some
+functional changes:
+Link: https://gitlab.freedesktop.org/drm/igt-gpu-tools/-/issues/138
+
+Upstream: https://lists.freedesktop.org/archives/igt-dev/2023-October/063817.html
+
+Signed-off-by: Mohammed Anas <triallax@tutanota.com>
+Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
+---
+ benchmarks/gem_exec_tracer.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
+index 7e86473e4..3156dfc23 100644
+--- a/benchmarks/gem_exec_tracer.c
++++ b/benchmarks/gem_exec_tracer.c
+@@ -271,7 +271,11 @@ static int is_i915(int fd)
+ }
+
+ int
++#ifdef __GLIBC__
+ ioctl(int fd, unsigned long request, ...)
++#else
++ioctl(int fd, int request, ...)
++#endif
+ {
+ struct trace *t, **p;
+ va_list args;
+--
+2.39.2
+
new file mode 100644
@@ -0,0 +1,33 @@
+config BR2_PACKAGE_IGT_GPU_TOOLS
+ bool "igt-gpu-tools"
+ depends on BR2_USE_MMU # fork()
+ depends on BR2_ENABLE_LOCALE
+ depends on !BR2_STATIC_LIBS
+ depends on BR2_TOOLCHAIN_HAS_THREADS
+ depends on BR2_PACKAGE_HAS_UDEV
+ depends on BR2_USE_WCHAR # elfutils
+ depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_11 # linux/dma-buf.h
+ depends on !BR2_RELRO_FULL
+ select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS # procps-ng
+ select BR2_PACKAGE_CAIRO
+ select BR2_PACKAGE_CAIRO_PNG
+ select BR2_PACKAGE_ELFUTILS
+ select BR2_PACKAGE_KMOD
+ select BR2_PACKAGE_LIBDRM
+ select BR2_PACKAGE_LIBGLIB2
+ select BR2_PACKAGE_LIBPCIACCESS
+ select BR2_PACKAGE_PIXMAN
+ select BR2_PACKAGE_PROCPS_NG
+ select BR2_PACKAGE_ZLIB
+ help
+ IGT GPU Tools is a collection of tools for development and
+ testing of the DRM drivers.
+
+ https://gitlab.freedesktop.org/drm/igt-gpu-tools
+
+comment "igt-gpu-tools needs udev /dev management and toolchain w/ threads, wchar, dynamic library, locale, headers >= 4.11"
+ depends on BR2_USE_MMU
+ depends on !BR2_PACKAGE_HAS_UDEV || BR2_STATIC_LIBS || \
+ !BR2_TOOLCHAIN_HAS_THREADS || !BR2_USE_WCHAR || \
+ !BR2_ENABLE_LOCALE || \
+ !BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_11
new file mode 100644
@@ -0,0 +1,5 @@
+# Locally calculated from download
+sha256 6f8b2b12704c0b37c22f32a3751688e7144f850faa715e85b26effdc5209cfd1 igt-gpu-tools-v1.28.tar.bz2
+
+# Hash for license file:
+sha256 1b7e266857b05808660f42369a4a797459d7b7bec7245e378aa28a8db2f213da COPYING
new file mode 100644
@@ -0,0 +1,29 @@
+################################################################################
+#
+# igt-gpu-tools
+#
+################################################################################
+
+IGT_GPU_TOOLS_VERSION = 1.28
+IGT_GPU_TOOLS_SOURCE = igt-gpu-tools-v$(IGT_GPU_TOOLS_VERSION).tar.bz2
+IGT_GPU_TOOLS_SITE = https://gitlab.freedesktop.org/drm/igt-gpu-tools/-/archive/v$(IGT_GPU_TOOLS_VERSION)
+IGT_GPU_TOOLS_LICENSE = MIT
+IGT_GPU_TOOLS_LICENSE_FILES = COPYING
+IGT_GPU_TOOLS_INSTALL_STAGING = YES
+IGT_GPU_TOOLS_DEPENDENCIES = host-pkgconf cairo elfutils kmod libdrm libglib2 libpciaccess pixman procps-ng zlib
+
+ifeq ($(BR2_PACKAGE_JSON_C),y)
+IGT_GPU_TOOLS_CONF_OPTS += -Drunner=enabled
+IGT_GPU_TOOLS_DEPENDENCIES += json-c
+else
+IGT_GPU_TOOLS_CONF_OPTS += -Drunner=disabled
+endif
+
+ifeq ($(BR2_PACKAGE_LIBUNWIND),y)
+IGT_GPU_TOOLS_CONF_OPTS += -Dlibunwind=enabled
+IGT_GPU_TOOLS_DEPENDENCIES += libunwind
+else
+IGT_GPU_TOOLS_CONF_OPTS += -Dlibunwind=disabled
+endif
+
+$(eval $(meson-package))