Skip to contentSkip to conversation

tools: remove unnecessary shared library

PATCH Superseded Sebastian Brzezinka 4 participants 70 messages Jul 3 – Jul 6

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover tools: remove unnecessary shared library

This issue was raised by the community back in 2019:
https://bugs.freedesktop.org/show_bug.cgi?id=110249

Standalone tools linked libigt.so as a side effect, pulling in cairo, pixman and libX11 even without framebuffer use.

Following intel_gpu_top's approach, each tool now links only the static sub-libraries it needs. Five new ones are introduced:

lib_igt_tools_stub, lib_igt_drm_stub, lib_igt_halffloat, lib_i915_decode, lib_igt_reg_tools.

igt_load_igtrc() is moved to igt_device_scan.c so lsgpu can use lib_igt_device_scan without pulling in libigt.so.

All 20 tools: 35 shared libs -> 3-8.

Behavioural differences vs original binaries (no-hardware runs):

intel_backlight, intel_lid, intel_gpu_time, intel_audio_dump, intel_infoframes, intel_panel_fitter, intel_firmware_decode:
assertion failure format: IGT CRITICAL block -> single-line message; exit code: 98 (IGT_EXIT_FAILURE) -> 1.

intel_gtt, intel_display_poller, intel_watermark:
same as above; additionally print an extra "Test requirement passed:
pci_dev" line on stderr (previously suppressed by IGT log layer).

intel_guc_logger:
same exit code change (98->1); --help drops IGT framework options (--list-subtests, --run-subtest, --device, etc.) which had no effect on guc_logger since it opens debugfs directly, not via IGT device selection; --version, --debug, --hook also removed. Unknown option exit code: 79 (IGT_EXIT_INVALID) -> 1.

intel_gvtg_test:
skip message: IGT skip block -> single-line; exit code unchanged (77).

Tested on Intel Meteor Lake-P (device 0x7d45) with the series applied:

lsgpu                enumerates card0/renderD128
intel_gpu_frequency  reads cur/min/max/RP1 frequencies
intel_stepping       reports device 0x7d45 rev 0x04
intel_error_decode   parses empty error state
igt_stats            computes median from stdin
intel_backlight      reads current backlight value: 0%
intel_gtt            dumps GTT linear mappings
intel_gpu_time       user: 0.000322s, GPU: 0.0%
intel_infoframes     runs, reports hardware not yet supported
intel_panel_fitter   shows usage with -l/-p/-x/-y options
intel_audio_dump     dumps meteorlake audio registers
intel_watermark      dumps WM_LINETIME and plane watermarks
intel_display_poller shows usage (requires --test option)
intel_lid            polls lid state: open (loops by design)
intel_forcewaked     locks forcewake, restarts daemon on gpu reset
intel_gvtg_test      exits 77, no GVT-g hardware
intel_guc_logger     --help prints usage correctly
intel_vbt_decode     --help prints usage correctly

intel_firmware_decode runs, fails on missing CSR file as expected
intel_dump_decode runs, rejects unknown options as expected
---
v1 -> v2:
- Rename all patch subjects
- Split  tools/intel_gtt  into two patches:  tools/intel_gtt  and  tools/intel_dump_decode
- Split  tools/lsgpu  into  lib/igt_core: move igt_load_igtrc to igt_device_scan  +  tools/lsgpu
- Shorten  tools/intel_gpu_top  subject (was over 72 chars)

Sebastian Brzezinka (31):
lib/igt_tools_stub: introduce static sub-library for tools lib/igt_stats: introduce static sub-library for tools tools/igt_stats: link with minimal sub-libraries tools/intel_firmware_decode: link with minimal sub-libraries lib/igt_tools_stub: add stubs needed by tools lib/igt_drm_stub: introduce for tools needing driver detection lib/igt_device_scan: wire to use static sub-libraries tools/intel_gpu_top: add explicit drm/tools-stub deps lib/igt_halffloat: introduce static sub-library for tools lib/i915/intel_decode: introduce static sub-library for tools lib/intel_mmio: introduce lib_igt_reg_tools static sub-library for
tools
tools/intel_gpu_frequency: link with minimal sub-libraries lib/i915/intel_decode: replace igt.h with minimal headers tools/intel_stepping: link with minimal sub-libraries tools/intel_gtt: link with minimal sub-libraries tools/intel_dump_decode: link with minimal sub-libraries tools/intel_error_decode: link with minimal sub-libraries tools/intel_vbt_decode: link with minimal sub-libraries tools/intel_backlight: link with minimal sub-libraries tools/intel_lid: link with minimal sub-libraries tools/intel_gpu_time: link with minimal sub-libraries tools/intel_audio_dump: link with minimal sub-libraries tools/intel_forcewaked: link with minimal sub-libraries tools/intel_guc_logger: link with minimal sub-libraries tools/intel_infoframes: link with minimal sub-libraries tools/intel_panel_fitter: link with minimal sub-libraries tools/intel_watermark: link with minimal sub-libraries tools/intel_display_poller: link with minimal sub-libraries tools/intel_gvtg_test: link with minimal sub-libraries lib/igt_core: move igt_load_igtrc to igt_device_scan tools/lsgpu: link with minimal sub-libraries

 lib/i915/intel_decode.c  |   4 +-
 lib/igt_core.c           |  47 --------------
 lib/igt_core.h           |   2 -
 lib/igt_device_scan.c    |  48 ++++++++++++++
 lib/igt_device_scan.h    |   2 +
 lib/igt_drm_stub.c       | 132 +++++++++++++++++++++++++++++++++++++++
 lib/igt_tools_stub.c     |  77 ++++++++++++++++++++---
 lib/meson.build          |  66 +++++++++++++++++++-
 tools/intel_guc_logger.c |  21 ++++++-
 tools/intel_gvtg_test.c  |   2 +-
 tools/lsgpu.c            |   2 +-
 tools/meson.build        | 126 ++++++++++++++++++++++++++++++-------
 12 files changed, 443 insertions(+), 86 deletions(-)
 create mode 100644 lib/igt_drm_stub.c
Signature · 1 line
2.53.0
#1 lore raw

PATCH v2 1/31 lib/igt_tools_stub: introduce static sub-library for tools

Add lib_igt_tools_stub built from igt_tools_stub.c. Tools that need minimal IGT assert/logging stubs can link this without pulling in the full libigt.so stack.

---
 lib/meson.build | 7 +++++++
 1 file changed, 7 insertions(+)
lib/meson.build +7 -0
index d1289a5e0..e95b29d49 100644
@@ -349,6 +349,13 @@ lib_igt_perf_build = static_library('igt_perf',
 lib_igt_perf = declare_dependency(link_with : lib_igt_perf_build,
 				  include_directories : inc)
 
+lib_igt_tools_stub_build = static_library('igt_tools_stub',
+	['igt_tools_stub.c'],
+	include_directories : inc)
+
+lib_igt_tools_stub = declare_dependency(link_with : lib_igt_tools_stub_build,
+					include_directories : inc)
+
 scan_dep = [
 	glib,
 	libpci,
Signature · 1 line
2.53.0
Reviewed-by on v2 1/31
#2 lore raw

Re: [PATCH i-g-t v2 01/31] lib/igt_tools_stub: introduce static sub-library for tools

Quoted 19 lines · Sebastian Brzezinka

Add lib_igt_tools_stub built from igt_tools_stub.c. Tools that need minimal IGT assert/logging stubs can link this without pulling in the full libigt.so stack.

---
 lib/meson.build | 7 +++++++
 1 file changed, 7 insertions(+)
lib/meson.build +0 -0
index d1289a5e0..e95b29d49 100644
@@ -349,6 +349,13 @@ lib_igt_perf_build = static_library('igt_perf',
 lib_igt_perf = declare_dependency(link_with : lib_igt_perf_build,
 				  include_directories : inc)
 

lib/meson.build lib_igt_perf_build = static_library('igt_perf', · line 361

Quoted 10 lines
lib/meson.build +7 -0
+lib_igt_tools_stub_build = static_library('igt_tools_stub',
+	['igt_tools_stub.c'],
+	include_directories : inc)
+
+lib_igt_tools_stub = declare_dependency(link_with : lib_igt_tools_stub_build,
+					include_directories : inc)
+
 scan_dep = [
 	glib,
 	libpci,

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#3 lore raw

PATCH v2 2/31 lib/igt_stats: introduce static sub-library for tools

In reply to Sebastian Brzezinka

Add lib_igt_stats built from igt_stats.c. Tools that need the statistics helpers can link this without pulling in the full libigt.so stack.

---
 lib/meson.build | 7 +++++++
 1 file changed, 7 insertions(+)
lib/meson.build +7 -0
index e95b29d49..a57c1eb8d 100644
@@ -397,6 +397,13 @@ lib_igt_profiling_build = static_library('igt_profiling',
 lib_igt_profiling = declare_dependency(link_with : lib_igt_profiling_build,
 				        include_directories : inc)
 
+lib_igt_stats_build = static_library('igt_stats_tools',
+	['igt_stats.c'],
+	include_directories : inc)
+
+lib_igt_stats = declare_dependency(link_with : lib_igt_stats_build,
+				   include_directories : inc)
+
 i915_perf_files = [
   'igt_list.c',
   'i915/perf.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 2/31
#4 lore raw

Re: [PATCH i-g-t v2 02/31] lib/igt_stats: introduce static sub-library for tools

Quoted 19 lines · Sebastian Brzezinka

Add lib_igt_stats built from igt_stats.c. Tools that need the statistics helpers can link this without pulling in the full libigt.so stack.

---
 lib/meson.build | 7 +++++++
 1 file changed, 7 insertions(+)
lib/meson.build +0 -0
index e95b29d49..a57c1eb8d 100644
@@ -397,6 +397,13 @@ lib_igt_profiling_build = static_library('igt_profiling',
 lib_igt_profiling = declare_dependency(link_with : lib_igt_profiling_build,
 				        include_directories : inc)
 

lib/meson.build lib_igt_profiling_build = static_library('igt_profiling', · line 409

Quoted 10 lines
lib/meson.build +7 -0
+lib_igt_stats_build = static_library('igt_stats_tools',
+	['igt_stats.c'],
+	include_directories : inc)
+
+lib_igt_stats = declare_dependency(link_with : lib_igt_stats_build,
+				   include_directories : inc)
+
 i915_perf_files = [
   'igt_list.c',
   'i915/perf.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#5 lore raw

PATCH v2 3/31 tools/igt_stats: link with minimal sub-libraries

In reply to Sebastian Brzezinka

igt_stats only needs the statistics helpers and a small assert stub. Link it against lib_igt_stats and lib_igt_tools_stub instead of the full libigt.so stack.

ldd before: 35 (ldd | wc -l)
ldd after: 4 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
index 8185ba160..286a718c8 100644
@@ -14,7 +14,6 @@ endforeach
 tools_progs = [
 	'igt_facts',
 	'igt_power',
-	'igt_stats',
 	'intel_audio_dump',
 	'intel_backlight',
 	'intel_bios_dumper',
@@ -58,6 +57,11 @@ foreach prog : tools_progs
 		   install : true)
 endforeach
 
+executable('igt_stats', 'igt_stats.c',
+	   dependencies : [lib_igt_stats, lib_igt_tools_stub, math],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 3/31
#6 lore raw

Re: [PATCH i-g-t v2 03/31] tools/igt_stats: link with minimal sub-libraries

Quoted 28 lines · Sebastian Brzezinka

igt_stats only needs the statistics helpers and a small assert stub. Link it against lib_igt_stats and lib_igt_tools_stub instead of the full libigt.so stack.

ldd before: 35 (ldd | wc -l)
ldd after: 4 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +0 -1
index 8185ba160..286a718c8 100644
@@ -14,7 +14,6 @@ endforeach
 tools_progs = [
 	'igt_facts',
 	'igt_power',
-	'igt_stats',
 	'intel_audio_dump',
 	'intel_backlight',
 	'intel_bios_dumper',
@@ -58,6 +57,11 @@ foreach prog : tools_progs
 		   install : true)

tools/meson.build foreach prog : tools_progs · line 67

Quoted 10 lines
tools/meson.build +5 -0
 endforeach
 
+executable('igt_stats', 'igt_stats.c',
+	   dependencies : [lib_igt_stats, lib_igt_tools_stub, math],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#7 lore raw

PATCH v2 4/31 tools/intel_firmware_decode: link with minimal sub-libraries

In reply to Sebastian Brzezinka

intel_firmware_decode only needs the lightweight assert stub used by igt_assert(), so the full libigt.so stack is unnecessary.

Switch to linking against lib_igt_tools_stub only.

ldd before: 35 (ldd | wc -l)
ldd after: 3 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
index 286a718c8..4c67dde4f 100644
@@ -24,7 +24,6 @@ tools_progs = [
 	'intel_error_decode',
 	'intel_forcewaked',
 	'intel_gpu_frequency',
-	'intel_firmware_decode',
 	'intel_framebuffer_dump',
 	'intel_gpu_time',
 	'intel_gtt',
@@ -62,6 +61,11 @@ executable('igt_stats', 'igt_stats.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)
 
+executable('intel_firmware_decode', 'intel_firmware_decode.c',
+	   dependencies : [lib_igt_tools_stub],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 4/31
#8 lore raw

Re: [PATCH i-g-t v2 04/31] tools/intel_firmware_decode: link with minimal sub-libraries

Quoted 29 lines · Sebastian Brzezinka

intel_firmware_decode only needs the lightweight assert stub used by igt_assert(), so the full libigt.so stack is unnecessary.

Switch to linking against lib_igt_tools_stub only.

ldd before: 35 (ldd | wc -l)
ldd after: 3 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +0 -1
index 286a718c8..4c67dde4f 100644
@@ -24,7 +24,6 @@ tools_progs = [
 	'intel_error_decode',
 	'intel_forcewaked',
 	'intel_gpu_frequency',
-	'intel_firmware_decode',
 	'intel_framebuffer_dump',
 	'intel_gpu_time',
 	'intel_gtt',
@@ -62,6 +61,11 @@ executable('igt_stats', 'igt_stats.c',
 	   install_rpath : bindir_rpathdir,

tools/meson.build executable('igt_stats', 'igt_stats.c', · line 71

Quoted 10 lines
tools/meson.build +5 -0
 	   install : true)
 
+executable('intel_firmware_decode', 'intel_firmware_decode.c',
+	   dependencies : [lib_igt_tools_stub],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#9 lore raw

PATCH v2 5/31 lib/igt_tools_stub: add stubs needed by tools

In reply to Sebastian Brzezinka

Add stubs for functions used by tools when linking without the full libigt.so: __igt_skip_check, igt_exit, igt_debugfs_open and igt_open_forcewake_handle_for_pcidev.

---
 lib/igt_tools_stub.c | 77 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 70 insertions(+), 7 deletions(-)
lib/igt_tools_stub.c +70 -7
index 9a0ec6217..71c850e2f 100644
@@ -21,12 +21,26 @@
  * IN THE SOFTWARE.
  *
  */
+#include <fcntl.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+#include <unistd.h>
+
 #include "igt_core.h"
+#include "igt_debugfs.h"
 
-/* Stub for igt_log, this stub will simply print the msg on stderr device.
- * Domain and log level are ignored.
+/*
+ * Forward declaration only - avoids pulling in the heavy igt_gt.h header.
+ * The type is used as an opaque pointer; this stub always returns -1.
  */
+struct pci_device;
+int igt_open_forcewake_handle_for_pcidev(const struct pci_device *pci_dev);
 
+/* Stub for igt_log: print message to stderr; domain and log level are ignored. */
 void igt_log(const char *domain, enum igt_log_level level, const char *format, ...)
 {
 	va_list args;
@@ -36,11 +50,7 @@ void igt_log(const char *domain, enum igt_log_level level, const char *format, .
 	va_end(args);
 }
 
-
-/* Stub for __igt_fail_assert, this stub will simply print the msg on stderr device and
- * exit the application, domain and log level are ignored.
- */
-
+/* Stub for __igt_fail_assert: print failed assertion to stderr and exit. */
 void __igt_fail_assert(const char *domain, const char *file,
 		       const int line, const char *func, const char *assertion,
 		       const char *format, ...)
@@ -49,3 +59,56 @@ void __igt_fail_assert(const char *domain, const char *file,
 		func, assertion);
 	exit(1);
 }
+
+/* Stub for __igt_skip_check: print skip reason to stderr and exit with skip code. */
+void __igt_skip_check(const char *file, const int line,
+		      const char *func, const char *check, const char *format, ...)
+{
+	fprintf(stderr, "%s: %d %s Skipped: %s", file, line, func, check);
+	if (format) {
+		va_list args;
+
+		fprintf(stderr, ": ");
+		va_start(args, format);
+		vfprintf(stderr, format, args);
+		va_end(args);
+	}
+	fprintf(stderr, "\n");
+	exit(77);
+}
+
+/* Stub for igt_exit: tools use exit(0) rather than the full igt teardown sequence. */
+__noreturn void igt_exit(void)
+{
+	exit(0);
+}
+
+/* Stub for igt_debugfs_open: open a debugfs entry for a DRM device directly by path.
+ * device == -1 follows the igt_debugfs_path() convention of defaulting to
+ * the first DRM device (dri/0).  When a valid fd is given, the DRM minor is
+ * resolved via fstat() so the correct dri/<minor> directory is used.
+ */
+int igt_debugfs_open(int device, const char *filename, int mode)
+{
+	char path[PATH_MAX];
+	int drm_minor = 0;
+
+	if (device >= 0) {
+		struct stat st;
+
+		if (fstat(device, &st) == 0 && S_ISCHR(st.st_mode))
+			drm_minor = minor(st.st_rdev);
+	}
+
+	snprintf(path, sizeof(path),
+		 "/sys/kernel/debug/dri/%d/%s", drm_minor, filename);
+	return open(path, mode);
+}
+
+/* Stub for igt_open_forcewake_handle_for_pcidev: in tool context the driver
+ * keeps the GPU awake; no forcewake handle needed.
+ */
+int igt_open_forcewake_handle_for_pcidev(const struct pci_device *pci_dev)
+{
+	return -1;
+}
Signature · 1 line
2.53.0
#10 lore raw

Re: [PATCH i-g-t v2 05/31] lib/igt_tools_stub: add stubs needed by tools

Quoted 67 lines · Sebastian Brzezinka

Add stubs for functions used by tools when linking without the full libigt.so: __igt_skip_check, igt_exit, igt_debugfs_open and igt_open_forcewake_handle_for_pcidev.

---
 lib/igt_tools_stub.c | 77 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 70 insertions(+), 7 deletions(-)
lib/igt_tools_stub.c +24 -7
index 9a0ec6217..71c850e2f 100644
@@ -21,12 +21,26 @@
  * IN THE SOFTWARE.
  *
  */
+#include <fcntl.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+#include <unistd.h>
+
 #include "igt_core.h"
+#include "igt_debugfs.h"
 
-/* Stub for igt_log, this stub will simply print the msg on stderr device.
- * Domain and log level are ignored.
+/*
+ * Forward declaration only - avoids pulling in the heavy igt_gt.h header.
+ * The type is used as an opaque pointer; this stub always returns -1.
  */
+struct pci_device;
+int igt_open_forcewake_handle_for_pcidev(const struct pci_device *pci_dev);
 
+/* Stub for igt_log: print message to stderr; domain and log level are ignored. */
 void igt_log(const char *domain, enum igt_log_level level, const char *format, ...)
 {
 	va_list args;
@@ -36,11 +50,7 @@ void igt_log(const char *domain, enum igt_log_level level, const char *format, .
 	va_end(args);
 }
 
-
-/* Stub for __igt_fail_assert, this stub will simply print the msg on stderr device and
- * exit the application, domain and log level are ignored.
- */
-
+/* Stub for __igt_fail_assert: print failed assertion to stderr and exit. */
 void __igt_fail_assert(const char *domain, const char *file,
 		       const int line, const char *func, const char *assertion,
 		       const char *format, ...)
@@ -49,3 +59,56 @@ void __igt_fail_assert(const char *domain, const char *file,
 		func, assertion);
 	exit(1);
 }
+
+/* Stub for __igt_skip_check: print skip reason to stderr and exit with skip code. */
+void __igt_skip_check(const char *file, const int line,
+		      const char *func, const char *check, const char *format, ...)
+{
+	fprintf(stderr, "%s: %d %s Skipped: %s", file, line, func, check);
+	if (format) {

lib/igt_tools_stub.c void __igt_fail_assert(const char *domain, const char *file, · line 78

Quoted 10 lines
lib/igt_tools_stub.c +10 -0
+		va_list args;
+
+		fprintf(stderr, ": ");
+		va_start(args, format);
+		vfprintf(stderr, format, args);
+		va_end(args);
+	}
+	fprintf(stderr, "\n");
+	exit(77);
+}

What is error 77 here? If you can't avoid the magic number at least leave a comment.

Also, the style in the codebase seems to be to leave an empty line directly after a block (so here it should be between the if closing curly brace and the fprintf), but this is a bit of a nit.

lib/igt_tools_stub.c void __igt_fail_assert(const char *domain, const char *file, · line 90

Quoted 12 lines
lib/igt_tools_stub.c +12 -0
+
+/* Stub for igt_exit: tools use exit(0) rather than the full igt teardown sequence. */
+__noreturn void igt_exit(void)
+{
+	exit(0);
+}
+
+/* Stub for igt_debugfs_open: open a debugfs entry for a DRM device directly by path.
+ * device == -1 follows the igt_debugfs_path() convention of defaulting to
+ * the first DRM device (dri/0).  When a valid fd is given, the DRM minor is
+ * resolved via fstat() so the correct dri/<minor> directory is used.
+ */

Unify multiline comments: before in the patch you're using

/*
* comment
* bla bla
*/

here it's

/* comment 2
* bla bla
*/

The rest of the codebase mostly uses the first variant, so I imagine it's better to use that; either way it should be made the same.

Quoted 10 lines
lib/igt_tools_stub.c +10 -0
+int igt_debugfs_open(int device, const char *filename, int mode)
+{
+	char path[PATH_MAX];
+	int drm_minor = 0;
+
+	if (device >= 0) {
+		struct stat st;
+
+		if (fstat(device, &st) == 0 && S_ISCHR(st.st_mode))
+			drm_minor = minor(st.st_rdev);

lib/igt_tools_stub.c void __igt_fail_assert(const char *domain, const char *file, · line 110

Quoted 10 lines
lib/igt_tools_stub.c +10 -0
+	}
+
+	snprintf(path, sizeof(path),
+		 "/sys/kernel/debug/dri/%d/%s", drm_minor, filename);
+	return open(path, mode);
+}
+
+/* Stub for igt_open_forcewake_handle_for_pcidev: in tool context the driver
+ * keeps the GPU awake; no forcewake handle needed.
+ */

Same issue with the comment as above.

Thanks
Krzysztof

Quoted 7 lines
lib/igt_tools_stub.c +4 -0
+int igt_open_forcewake_handle_for_pcidev(const struct pci_device *pci_dev)
+{
+	return -1;
+}
Signature · 1 line
2.53.0
#11 lore raw

PATCH v2 6/31 lib/igt_drm_stub: introduce for tools needing driver detection

In reply to Sebastian Brzezinka

Add drm/pciaccess-dependent stubs into a new igt_drm_stub.c. This avoids pulling libdrm into tools that only need dep-free logging and exit stubs.

The new lib_igt_drm_stub static sub-library provides: igt_pci_system_init, is_i915_device, is_intel_device, xe_dev_id and __drm_open_driver.

---
 lib/igt_drm_stub.c | 132 +++++++++++++++++++++++++++++++++++++++++++++
 lib/meson.build    |   9 ++++
 2 files changed, 141 insertions(+)
 create mode 100644 lib/igt_drm_stub.c
lib/igt_drm_stub.c new file +132 -0
new file mode 100644
index 000000000..f8ac3a992
@@ -0,0 +1,132 @@
+/*
+ * Copyright © 2026 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.
+ */
+
+/*
+ * Minimal DRM/PCI stubs for tools that need driver detection and device
+ * opening but do not link the full libigt.so.  Requires libdrm and pciaccess.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <pciaccess.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+#include <unistd.h>
+#include <xf86drm.h>
+
+#include "drmtest.h"
+
+int igt_pci_system_init(void)
+{
+	return pci_system_init();
+}
+
+static bool driver_name_matches(int fd, const char *name)
+{
+	drmVersionPtr version;
+	bool match = false;
+
+	version = drmGetVersion(fd);
+	if (!version)
+		return false;
+
+	match = version->name_len > 0 && !strcmp(version->name, name);
+	drmFreeVersion(version);
+
+	return match;
+}
+
+bool is_i915_device(int fd)
+{
+	return driver_name_matches(fd, "i915");
+}
+
+bool is_intel_device(int fd)
+{
+	return is_i915_device(fd) || driver_name_matches(fd, "xe");
+}
+
+static uint16_t read_pci_device_id(int fd)
+{
+	char path[PATH_MAX], buf[32];
+	struct stat st;
+	int sysfs, len;
+	unsigned int devid;
+
+	if (fstat(fd, &st) || !S_ISCHR(st.st_mode))
+		return 0;
+
+	snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device/device",
+		 major(st.st_rdev), minor(st.st_rdev));
+	sysfs = open(path, O_RDONLY);
+	if (sysfs < 0)
+		return 0;
+
+	len = read(sysfs, buf, sizeof(buf) - 1);
+	close(sysfs);
+	if (len <= 0)
+		return 0;
+
+	buf[len] = '\0';
+	if (sscanf(buf, "0x%x", &devid) != 1)
+		return 0;
+
+	return devid;
+}
+
+/* Matches the declaration in lib/xe/xe_query.h declared here to satisfy
+ * -Wmissing-prototypes without pulling in the heavy xe_query.h header.
+ */
+uint16_t xe_dev_id(int fd);
+uint16_t xe_dev_id(int fd)
+{
+	return read_pci_device_id(fd);
+}
+
+int __drm_open_driver(int chipset)
+{
+	char path[PATH_MAX];
+	int fd;
+
+	for (int i = 0; i < 16; i++) {
+		snprintf(path, sizeof(path), "/dev/dri/card%d", i);
+		fd = open(path, O_RDWR | O_CLOEXEC);
+		if (fd < 0)
+			continue;
+
+		if ((chipset == DRIVER_INTEL && is_i915_device(fd)) ||
+		    (chipset == DRIVER_XE && driver_name_matches(fd, "xe")) ||
+		    (chipset == DRIVER_ANY && is_intel_device(fd)))
+			return fd;
+
+		close(fd);
+	}
+
+	errno = ENODEV;
+	return -1;
+}
lib/meson.build +9 -0
index a57c1eb8d..484a912d7 100644
@@ -356,6 +356,15 @@ lib_igt_tools_stub_build = static_library('igt_tools_stub',
 lib_igt_tools_stub = declare_dependency(link_with : lib_igt_tools_stub_build,
 					include_directories : inc)
 
+lib_igt_drm_stub_build = static_library('igt_drm_stub',
+	['igt_drm_stub.c'],
+	dependencies : [libdrm, pciaccess],
+	include_directories : inc)
+
+lib_igt_drm_stub = declare_dependency(link_with : lib_igt_drm_stub_build,
+				      dependencies : [libdrm, pciaccess],
+				      include_directories : inc)
+
 scan_dep = [
 	glib,
 	libpci,
Signature · 1 line
2.53.0
Reviewed-by on v2 6/31
#12 lore raw

Re: [PATCH i-g-t v2 06/31] lib/igt_drm_stub: introduce for tools needing driver detection

Quoted 114 lines · Sebastian Brzezinka

Add drm/pciaccess-dependent stubs into a new igt_drm_stub.c. This avoids pulling libdrm into tools that only need dep-free logging and exit stubs.

The new lib_igt_drm_stub static sub-library provides: igt_pci_system_init, is_i915_device, is_intel_device, xe_dev_id and __drm_open_driver.

---
 lib/igt_drm_stub.c | 132 +++++++++++++++++++++++++++++++++++++++++++++
 lib/meson.build    |   9 ++++
 2 files changed, 141 insertions(+)
 create mode 100644 lib/igt_drm_stub.c
lib/igt_drm_stub.c new file +94 -0
new file mode 100644
index 000000000..f8ac3a992
@@ -0,0 +1,132 @@
+/*
+ * Copyright © 2026 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.
+ */
+
+/*
+ * Minimal DRM/PCI stubs for tools that need driver detection and device
+ * opening but do not link the full libigt.so.  Requires libdrm and pciaccess.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <pciaccess.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+#include <unistd.h>
+#include <xf86drm.h>
+
+#include "drmtest.h"
+
+int igt_pci_system_init(void)
+{
+	return pci_system_init();
+}
+
+static bool driver_name_matches(int fd, const char *name)
+{
+	drmVersionPtr version;
+	bool match = false;
+
+	version = drmGetVersion(fd);
+	if (!version)
+		return false;
+
+	match = version->name_len > 0 && !strcmp(version->name, name);
+	drmFreeVersion(version);
+
+	return match;
+}
+
+bool is_i915_device(int fd)
+{
+	return driver_name_matches(fd, "i915");
+}
+
+bool is_intel_device(int fd)
+{
+	return is_i915_device(fd) || driver_name_matches(fd, "xe");
+}
+
+static uint16_t read_pci_device_id(int fd)
+{
+	char path[PATH_MAX], buf[32];
+	struct stat st;
+	int sysfs, len;
+	unsigned int devid;
+
+	if (fstat(fd, &st) || !S_ISCHR(st.st_mode))
+		return 0;
+
+	snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device/device",
+		 major(st.st_rdev), minor(st.st_rdev));
+	sysfs = open(path, O_RDONLY);
+	if (sysfs < 0)
+		return 0;
+
+	len = read(sysfs, buf, sizeof(buf) - 1);
+	close(sysfs);
+	if (len <= 0)
+		return 0;
+

lib/igt_drm_stub.c line 104

Quoted 10 lines
lib/igt_drm_stub.c new file +10 -0
+	buf[len] = '\0';
+	if (sscanf(buf, "0x%x", &devid) != 1)
+		return 0;
+
+	return devid;
+}
+
+/* Matches the declaration in lib/xe/xe_query.h declared here to satisfy
+ * -Wmissing-prototypes without pulling in the heavy xe_query.h header.
+ */

Same thing with comments as in the previous patch; I'll omit pointing out any other places in the rest of the series - but just for the sake of brevity, the comments should be unified everywhere.

lib/igt_drm_stub.c line 110

Quoted 6 lines
lib/igt_drm_stub.c new file +6 -0
+uint16_t xe_dev_id(int fd);
+uint16_t xe_dev_id(int fd)
+{
+	return read_pci_device_id(fd);
+}
+

Why can't the users of this function just use read_pci_device_id() directly? It's not i915-specific. The function declaration looks very hacky. But I guess it's kind of unavoidable if you don't want a separate .h file. Ack from me on this if there's not a cleaner way to do this.

Quoted 33 lines
lib/igt_drm_stub.c new file +22 -0
+int __drm_open_driver(int chipset)
+{
+	char path[PATH_MAX];
+	int fd;
+
+	for (int i = 0; i < 16; i++) {
+		snprintf(path, sizeof(path), "/dev/dri/card%d", i);
+		fd = open(path, O_RDWR | O_CLOEXEC);
+		if (fd < 0)
+			continue;
+
+		if ((chipset == DRIVER_INTEL && is_i915_device(fd)) ||
+		    (chipset == DRIVER_XE && driver_name_matches(fd, "xe")) ||
+		    (chipset == DRIVER_ANY && is_intel_device(fd)))
+			return fd;
+
+		close(fd);
+	}
+
+	errno = ENODEV;
+	return -1;
+}
lib/meson.build +2 -0
index a57c1eb8d..484a912d7 100644
@@ -356,6 +356,15 @@ lib_igt_tools_stub_build = static_library('igt_tools_stub',
 lib_igt_tools_stub = declare_dependency(link_with : lib_igt_tools_stub_build,
 					include_directories : inc)
 
+lib_igt_drm_stub_build = static_library('igt_drm_stub',
+	['igt_drm_stub.c'],

lib/meson.build lib_igt_tools_stub_build = static_library('igt_tools_stub', · line 370

Quoted 10 lines
lib/meson.build +7 -0
+	dependencies : [libdrm, pciaccess],
+	include_directories : inc)
+
+lib_igt_drm_stub = declare_dependency(link_with : lib_igt_drm_stub_build,
+				      dependencies : [libdrm, pciaccess],
+				      include_directories : inc)
+
 scan_dep = [
 	glib,
 	libpci,

With the comments fixed:

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#13 lore raw

Re: [PATCH i-g-t v2 06/31] lib/igt_drm_stub: introduce for tools needing driver detection

In reply to Sebastian Brzezinka

Hi Sebastian,

Quoted 20 lines · Sebastian Brzezinka

Add drm/pciaccess-dependent stubs into a new igt_drm_stub.c. This avoids pulling libdrm into tools that only need dep-free logging and exit stubs.

The new lib_igt_drm_stub static sub-library provides: igt_pci_system_init, is_i915_device, is_intel_device, xe_dev_id and __drm_open_driver.

---
 lib/igt_drm_stub.c | 132 +++++++++++++++++++++++++++++++++++++++++++++
 lib/meson.build    |   9 ++++
 2 files changed, 141 insertions(+)
 create mode 100644 lib/igt_drm_stub.c
lib/igt_drm_stub.c new file +0 -0
new file mode 100644
index 000000000..f8ac3a992

lib/igt_drm_stub.c line 4

Quoted 4 lines
lib/igt_drm_stub.c new file +4 -0
@@ -0,0 +1,132 @@
+/*
+ * Copyright © 2026 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a

Please remove this long text and use SPDX instead.

Quoted 12 lines
lib/igt_drm_stub.c new file +12 -0
+ * 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,

lib/igt_drm_stub.c line 26

Quoted 10 lines
lib/igt_drm_stub.c new file +10 -0
+ * 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.
+ */
+
+/*
+ * Minimal DRM/PCI stubs for tools that need driver detection and device
+ * opening but do not link the full libigt.so.  Requires libdrm and pciaccess.

Please also write that this is a reimplemntation, and write down which libs it is reimplementing.

Quoted 69 lines
lib/igt_drm_stub.c new file +69 -0
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <pciaccess.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+#include <unistd.h>
+#include <xf86drm.h>
+
+#include "drmtest.h"
+
+int igt_pci_system_init(void)
+{
+	return pci_system_init();
+}
+
+static bool driver_name_matches(int fd, const char *name)
+{
+	drmVersionPtr version;
+	bool match = false;
+
+	version = drmGetVersion(fd);
+	if (!version)
+		return false;
+
+	match = version->name_len > 0 && !strcmp(version->name, name);
+	drmFreeVersion(version);
+
+	return match;
+}
+
+bool is_i915_device(int fd)
+{
+	return driver_name_matches(fd, "i915");
+}
+
+bool is_intel_device(int fd)
+{
+	return is_i915_device(fd) || driver_name_matches(fd, "xe");
+}
+
+static uint16_t read_pci_device_id(int fd)
+{
+	char path[PATH_MAX], buf[32];
+	struct stat st;
+	int sysfs, len;
+	unsigned int devid;
+
+	if (fstat(fd, &st) || !S_ISCHR(st.st_mode))
+		return 0;
+
+	snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device/device",
+		 major(st.st_rdev), minor(st.st_rdev));
+	sysfs = open(path, O_RDONLY);
+	if (sysfs < 0)
+		return 0;
+
+	len = read(sysfs, buf, sizeof(buf) - 1);
+	close(sysfs);
+	if (len <= 0)
+		return 0;
+
+	buf[len] = '\0';

lib/igt_drm_stub.c line 105

Quoted 10 lines
lib/igt_drm_stub.c new file +10 -0
+	if (sscanf(buf, "0x%x", &devid) != 1)
+		return 0;
+
+	return devid;
+}
+
+/* Matches the declaration in lib/xe/xe_query.h declared here to satisfy
+ * -Wmissing-prototypes without pulling in the heavy xe_query.h header.
+ */
+uint16_t xe_dev_id(int fd);

Why do you repeat it when it is just below?

lib/igt_drm_stub.c line 116

Quoted 11 lines
lib/igt_drm_stub.c new file +11 -0
+uint16_t xe_dev_id(int fd)
+{
+	return read_pci_device_id(fd);
+}
+
+int __drm_open_driver(int chipset)
+{
+	char path[PATH_MAX];
+	int fd;
+
+	for (int i = 0; i < 16; i++) {

Looks like we need a separate header with few magic constants, like 16 here.

Regards,
Kamil

Quoted 39 lines
lib/igt_drm_stub.c new file +16 -0
+		snprintf(path, sizeof(path), "/dev/dri/card%d", i);
+		fd = open(path, O_RDWR | O_CLOEXEC);
+		if (fd < 0)
+			continue;
+
+		if ((chipset == DRIVER_INTEL && is_i915_device(fd)) ||
+		    (chipset == DRIVER_XE && driver_name_matches(fd, "xe")) ||
+		    (chipset == DRIVER_ANY && is_intel_device(fd)))
+			return fd;
+
+		close(fd);
+	}
+
+	errno = ENODEV;
+	return -1;
+}
lib/meson.build +9 -0
index a57c1eb8d..484a912d7 100644
@@ -356,6 +356,15 @@ lib_igt_tools_stub_build = static_library('igt_tools_stub',
 lib_igt_tools_stub = declare_dependency(link_with : lib_igt_tools_stub_build,
 					include_directories : inc)
 
+lib_igt_drm_stub_build = static_library('igt_drm_stub',
+	['igt_drm_stub.c'],
+	dependencies : [libdrm, pciaccess],
+	include_directories : inc)
+
+lib_igt_drm_stub = declare_dependency(link_with : lib_igt_drm_stub_build,
+				      dependencies : [libdrm, pciaccess],
+				      include_directories : inc)
+
 scan_dep = [
 	glib,
 	libpci,
Signature · 1 line
2.53.0
#14 lore raw

PATCH v2 7/31 lib/igt_device_scan: wire to use static sub-libraries

In reply to Sebastian Brzezinka

Drop the directly compiled igt_tools_stub.c from lib_igt_device_scan and link lib_igt_tools_stub and lib_igt_drm_stub instead. Compiling igt_tools_stub.c directly would cause duplicate symbol errors when a tool links both lib_igt_device_scan and lib_igt_tools_stub.

Add libdrm and pciaccess to scan_dep so tools linking lib_igt_device_scan pick up the right dependencies.

---
 lib/meson.build | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
lib/meson.build +4 -2
index 484a912d7..2c1fbcd43 100644
@@ -367,22 +367,24 @@ lib_igt_drm_stub = declare_dependency(link_with : lib_igt_drm_stub_build,
 
 scan_dep = [
 	glib,
+	libdrm,
 	libpci,
 	libudev,
+	pciaccess,
 ]
 
 lib_igt_device_scan_build = static_library('igt_device_scan',
 	['igt_device_scan.c',
 	'igt_list.c',
 	'igt_map.c',
-	'igt_tools_stub.c',
 	'intel_device_info.c',
 	'intel_cmds_info.c',
 	],
-	dependencies : scan_dep,
+	dependencies : [scan_dep, lib_igt_drm_stub, lib_igt_tools_stub],
 	include_directories : inc)
 
 lib_igt_device_scan = declare_dependency(link_with : lib_igt_device_scan_build,
+				  dependencies : [libdrm, pciaccess],
 				  include_directories : inc)
 
 lib_igt_drm_clients_build = static_library('igt_drm_clients',
Signature · 1 line
2.53.0
Reviewed-by on v2 7/31
#15 lore raw

Re: [PATCH i-g-t v2 07/31] lib/igt_device_scan: wire to use static sub-libraries

Quoted 35 lines · Sebastian Brzezinka

Drop the directly compiled igt_tools_stub.c from lib_igt_device_scan and link lib_igt_tools_stub and lib_igt_drm_stub instead. Compiling igt_tools_stub.c directly would cause duplicate symbol errors when a tool links both lib_igt_device_scan and lib_igt_tools_stub.

Add libdrm and pciaccess to scan_dep so tools linking lib_igt_device_scan pick up the right dependencies.

---
 lib/meson.build | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
lib/meson.build +2 -1
index 484a912d7..2c1fbcd43 100644
@@ -367,22 +367,24 @@ lib_igt_drm_stub = declare_dependency(link_with : lib_igt_drm_stub_build,
 
 scan_dep = [
 	glib,
+	libdrm,
 	libpci,
 	libudev,
+	pciaccess,
 ]
 
 lib_igt_device_scan_build = static_library('igt_device_scan',
 	['igt_device_scan.c',
 	'igt_list.c',
 	'igt_map.c',
-	'igt_tools_stub.c',
 	'intel_device_info.c',
 	'intel_cmds_info.c',

lib/meson.build lib_igt_drm_stub = declare_dependency(link_with : lib_igt_drm_stub_build, · line 390

Quoted 10 lines
lib/meson.build +2 -1
 	],
-	dependencies : scan_dep,
+	dependencies : [scan_dep, lib_igt_drm_stub, lib_igt_tools_stub],
 	include_directories : inc)
 
 lib_igt_device_scan = declare_dependency(link_with : lib_igt_device_scan_build,
+				  dependencies : [libdrm, pciaccess],
 				  include_directories : inc)
 
 lib_igt_drm_clients_build = static_library('igt_drm_clients',

Thanks
Krzysztof

Quoted 3 lines
Signature · 1 line
2.53.0
#16 lore raw

PATCH v2 8/31 tools/intel_gpu_top: add explicit drm/tools-stub deps

In reply to Sebastian Brzezinka

Meson does not automatically propagate static library dependencies to executables via link_with. lib_igt_device_scan internally links lib_igt_drm_stub and lib_igt_tools_stub but does not reexport them through its declare_dependency. As a result intel_gpu_top must list them explicitly, otherwise the linker cannot resolve symbols such as is_i915_device and igt_log at final link time.

---
 tools/meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/meson.build +2 -1
index 4c67dde4f..53aa31056 100644
@@ -105,7 +105,8 @@ install_subdir('registers', install_dir : datadir)
 executable('intel_gpu_top', 'intel_gpu_top.c',
 	   install : true,
 	   install_rpath : bindir_rpathdir,
-	   dependencies : [lib_igt_perf,lib_igt_device_scan,lib_igt_drm_clients,lib_igt_drm_fdinfo,math])
+	   dependencies : [lib_igt_perf,lib_igt_device_scan,lib_igt_drm_clients,lib_igt_drm_fdinfo,
+	                   lib_igt_drm_stub, lib_igt_tools_stub, math])
 
 executable('amd_hdmi_compliance', 'amd_hdmi_compliance.c',
 	   dependencies : [tool_deps],
Signature · 1 line
2.53.0
Reviewed-by on v2 8/31
#17 lore raw

Re: [PATCH i-g-t v2 08/31] tools/intel_gpu_top: add explicit drm/tools-stub deps

Quoted 19 lines · Sebastian Brzezinka

Meson does not automatically propagate static library dependencies to executables via link_with. lib_igt_device_scan internally links lib_igt_drm_stub and lib_igt_tools_stub but does not reexport them through its declare_dependency. As a result intel_gpu_top must list them explicitly, otherwise the linker cannot resolve symbols such as is_i915_device and igt_log at final link time.

---
 tools/meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/meson.build +0 -0
index 4c67dde4f..53aa31056 100644

tools/meson.build install_subdir('registers', install_dir : datadir) · line 112

Quoted 9 lines
tools/meson.build +2 -1
@@ -105,7 +105,8 @@ install_subdir('registers', install_dir : datadir)
 executable('intel_gpu_top', 'intel_gpu_top.c',
 	   install : true,
 	   install_rpath : bindir_rpathdir,
-	   dependencies : [lib_igt_perf,lib_igt_device_scan,lib_igt_drm_clients,lib_igt_drm_fdinfo,math])
+	   dependencies : [lib_igt_perf,lib_igt_device_scan,lib_igt_drm_clients,lib_igt_drm_fdinfo,
+	                   lib_igt_drm_stub, lib_igt_tools_stub, math])
 
 executable('amd_hdmi_compliance', 'amd_hdmi_compliance.c',
 	   dependencies : [tool_deps],

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#18 lore raw

PATCH v2 9/31 lib/igt_halffloat: introduce static sub-library for tools

In reply to Sebastian Brzezinka

Add lib_igt_halffloat backed by igt_halffloat.c with a math dependency. Tools that use half-float conversion (e.g. intel_vbt_decode) can link this minimal library instead of the full libigt.so.

---
 lib/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/meson.build +8 -0
index 2c1fbcd43..93db217f8 100644
@@ -415,6 +415,14 @@ lib_igt_stats_build = static_library('igt_stats_tools',
 lib_igt_stats = declare_dependency(link_with : lib_igt_stats_build,
 				   include_directories : inc)
 
+lib_igt_halffloat_build = static_library('igt_halffloat',
+	['igt_halffloat.c'],
+	include_directories : inc)
+
+lib_igt_halffloat = declare_dependency(link_with : lib_igt_halffloat_build,
+				       dependencies : [math],
+				       include_directories : inc)
+
 i915_perf_files = [
   'igt_list.c',
   'i915/perf.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 9/31
#19 lore raw

Re: [PATCH i-g-t v2 09/31] lib/igt_halffloat: introduce static sub-library for tools

Quoted 20 lines · Sebastian Brzezinka

Add lib_igt_halffloat backed by igt_halffloat.c with a math dependency. Tools that use half-float conversion (e.g. intel_vbt_decode) can link this minimal library instead of the full libigt.so.

---
 lib/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/meson.build +1 -0
index 2c1fbcd43..93db217f8 100644
@@ -415,6 +415,14 @@ lib_igt_stats_build = static_library('igt_stats_tools',
 lib_igt_stats = declare_dependency(link_with : lib_igt_stats_build,
 				   include_directories : inc)
 
+lib_igt_halffloat_build = static_library('igt_halffloat',

lib/meson.build lib_igt_stats_build = static_library('igt_stats_tools', · line 428

Quoted 10 lines
lib/meson.build +7 -0
+	['igt_halffloat.c'],
+	include_directories : inc)
+
+lib_igt_halffloat = declare_dependency(link_with : lib_igt_halffloat_build,
+				       dependencies : [math],
+				       include_directories : inc)
+
 i915_perf_files = [
   'igt_list.c',
   'i915/perf.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#20 lore raw

PATCH v2 10/31 lib/i915/intel_decode: introduce static sub-library for tools

In reply to Sebastian Brzezinka

Add lib_i915_decode built from i915/intel_decode.c and instdone.c. This lets tools like intel_error_decode link only the decode logic without pulling in the full libigt.so.

---
 lib/meson.build | 12 ++++++++++++
 1 file changed, 12 insertions(+)
lib/meson.build +12 -0
index 93db217f8..ba4ece3a2 100644
@@ -423,6 +423,18 @@ lib_igt_halffloat = declare_dependency(link_with : lib_igt_halffloat_build,
 				       dependencies : [math],
 				       include_directories : inc)
 
+lib_i915_decode_build = static_library('i915_decode',
+	['i915/intel_decode.c',
+	 'instdone.c',
+	],
+	dependencies : [lib_igt_chipset],
+	include_directories : inc)
+
+lib_i915_decode = declare_dependency(link_with : lib_i915_decode_build,
+				     dependencies : [lib_igt_chipset,
+				                     lib_igt_tools_stub],
+				     include_directories : inc)
+
 i915_perf_files = [
   'igt_list.c',
   'i915/perf.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 10/31
#21 lore raw

Re: [PATCH i-g-t v2 10/31] lib/i915/intel_decode: introduce static sub-library for tools

Quoted 24 lines · Sebastian Brzezinka

Add lib_i915_decode built from i915/intel_decode.c and instdone.c. This lets tools like intel_error_decode link only the decode logic without pulling in the full libigt.so.

---
 lib/meson.build | 12 ++++++++++++
 1 file changed, 12 insertions(+)
lib/meson.build +5 -0
index 93db217f8..ba4ece3a2 100644
@@ -423,6 +423,18 @@ lib_igt_halffloat = declare_dependency(link_with : lib_igt_halffloat_build,
 				       dependencies : [math],
 				       include_directories : inc)
 
+lib_i915_decode_build = static_library('i915_decode',
+	['i915/intel_decode.c',
+	 'instdone.c',
+	],
+	dependencies : [lib_igt_chipset],

lib/meson.build lib_igt_halffloat = declare_dependency(link_with : lib_igt_halffloat_build, · line 440

Quoted 10 lines
lib/meson.build +7 -0
+	include_directories : inc)
+
+lib_i915_decode = declare_dependency(link_with : lib_i915_decode_build,
+				     dependencies : [lib_igt_chipset,
+				                     lib_igt_tools_stub],
+				     include_directories : inc)
+
 i915_perf_files = [
   'igt_list.c',
   'i915/perf.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#22 lore raw

Re: [PATCH i-g-t v2 10/31] lib/i915/intel_decode: introduce static sub-library for tools

In reply to Sebastian Brzezinka

Hi Sebastian,

Quoted 6 lines · Sebastian Brzezinka

Add lib_i915_decode built from i915/intel_decode.c and instdone.c. This lets tools like intel_error_decode link only the decode logic without pulling in the full libigt.so.

Please make sure your series will compile patch after patch, so bisetion will work. Here, this patch breaks it:

./lib/igt_fb.h:32:10: fatal error: cairo.h: No such file or directory
32 | #include <cairo.h>

         |          ^~~~~~~~~
	 compilation terminated.

One way to do it: git rebase -i origin -x 'ninja -C build' but when you introduce changes in meson.build it is better to have a script which will delete build folder first and then builds:
git rebase -i origin -x ./compile.sh

Regards,
Kamil

Quoted 30 lines
---
 lib/meson.build | 12 ++++++++++++
 1 file changed, 12 insertions(+)
lib/meson.build +12 -0
index 93db217f8..ba4ece3a2 100644
@@ -423,6 +423,18 @@ lib_igt_halffloat = declare_dependency(link_with : lib_igt_halffloat_build,
 				       dependencies : [math],
 				       include_directories : inc)
 
+lib_i915_decode_build = static_library('i915_decode',
+	['i915/intel_decode.c',
+	 'instdone.c',
+	],
+	dependencies : [lib_igt_chipset],
+	include_directories : inc)
+
+lib_i915_decode = declare_dependency(link_with : lib_i915_decode_build,
+				     dependencies : [lib_igt_chipset,
+				                     lib_igt_tools_stub],
+				     include_directories : inc)
+
 i915_perf_files = [
   'igt_list.c',
   'i915/perf.c',
Signature · 1 line
2.53.0
#23 lore raw

PATCH v2 11/31 lib/intel_mmio: introduce lib_igt_reg_tools static sub-library for tools

In reply to Sebastian Brzezinka

Add lib_igt_reg_tools built from intel_mmio.c, intel_reg_map.c and intel_iosf.c. Tools that need register access (e.g. intel_reg) can link this library without pulling in the full libigt.so.

---
 lib/meson.build | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
lib/meson.build +15 -0
index ba4ece3a2..43ae4ce66 100644
@@ -435,6 +435,21 @@ lib_i915_decode = declare_dependency(link_with : lib_i915_decode_build,
 				                     lib_igt_tools_stub],
 				     include_directories : inc)
 
+lib_igt_reg_tools_build = static_library('igt_reg_tools',
+	['intel_mmio.c',
+	 'intel_reg_map.c',
+	 'intel_iosf.c',
+	],
+	dependencies : [pciaccess, libdrm],
+	include_directories : inc)
+
+lib_igt_reg_tools = declare_dependency(link_with : lib_igt_reg_tools_build,
+				       dependencies : [lib_igt_chipset,
+				                       lib_igt_tools_stub,
+				                       lib_igt_drm_stub,
+				                       pciaccess, libdrm],
+				       include_directories : inc)
+
 i915_perf_files = [
   'igt_list.c',
   'i915/perf.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 11/31
#24 lore raw

Re: [PATCH i-g-t v2 11/31] lib/intel_mmio: introduce lib_igt_reg_tools static sub-library for tools

Quoted 27 lines · Sebastian Brzezinka

Add lib_igt_reg_tools built from intel_mmio.c, intel_reg_map.c and intel_iosf.c. Tools that need register access (e.g. intel_reg) can link this library without pulling in the full libigt.so.

---
 lib/meson.build | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
lib/meson.build +8 -0
index ba4ece3a2..43ae4ce66 100644
@@ -435,6 +435,21 @@ lib_i915_decode = declare_dependency(link_with : lib_i915_decode_build,
 				                     lib_igt_tools_stub],
 				     include_directories : inc)
 
+lib_igt_reg_tools_build = static_library('igt_reg_tools',
+	['intel_mmio.c',
+	 'intel_reg_map.c',
+	 'intel_iosf.c',
+	],
+	dependencies : [pciaccess, libdrm],
+	include_directories : inc)
+

lib/meson.build lib_i915_decode = declare_dependency(link_with : lib_i915_decode_build, · line 455

Quoted 10 lines
lib/meson.build +7 -0
+lib_igt_reg_tools = declare_dependency(link_with : lib_igt_reg_tools_build,
+				       dependencies : [lib_igt_chipset,
+				                       lib_igt_tools_stub,
+				                       lib_igt_drm_stub,
+				                       pciaccess, libdrm],
+				       include_directories : inc)
+
 i915_perf_files = [
   'igt_list.c',
   'i915/perf.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#25 lore raw

PATCH v2 12/31 tools/intel_gpu_frequency: link with minimal sub-libraries

In reply to Sebastian Brzezinka

intel_gpu_frequency needs only intel_gen/devid helpers and a DRM device opener to query the GPU frequency. Link it against lib_igt_chipset for the devid helpers and lib_igt_drm_stub for driver detection and device opening, instead of the full libigt.so stack.

ldd before: 35 (ldd intel_gpu_frequency | wc -l)
ldd after: 5 (ldd intel_gpu_frequency | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
index 53aa31056..01400f53e 100644
@@ -23,7 +23,6 @@ tools_progs = [
 	'intel_dump_decode',
 	'intel_error_decode',
 	'intel_forcewaked',
-	'intel_gpu_frequency',
 	'intel_framebuffer_dump',
 	'intel_gpu_time',
 	'intel_gtt',
@@ -66,6 +65,11 @@ executable('intel_firmware_decode', 'intel_firmware_decode.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)
 
+executable('intel_gpu_frequency', 'intel_gpu_frequency.c',
+	   dependencies : [lib_igt_chipset, lib_igt_tools_stub, lib_igt_drm_stub],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 12/31
#26 lore raw

Re: [PATCH i-g-t v2 12/31] tools/intel_gpu_frequency: link with minimal sub-libraries

Quoted 29 lines · Sebastian Brzezinka

intel_gpu_frequency needs only intel_gen/devid helpers and a DRM device opener to query the GPU frequency. Link it against lib_igt_chipset for the devid helpers and lib_igt_drm_stub for driver detection and device opening, instead of the full libigt.so stack.

ldd before: 35 (ldd intel_gpu_frequency | wc -l)
ldd after: 5 (ldd intel_gpu_frequency | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +0 -1
index 53aa31056..01400f53e 100644
@@ -23,7 +23,6 @@ tools_progs = [
 	'intel_dump_decode',
 	'intel_error_decode',
 	'intel_forcewaked',
-	'intel_gpu_frequency',
 	'intel_framebuffer_dump',
 	'intel_gpu_time',
 	'intel_gtt',
@@ -66,6 +65,11 @@ executable('intel_firmware_decode', 'intel_firmware_decode.c',
 	   install_rpath : bindir_rpathdir,

tools/meson.build executable('intel_firmware_decode', 'intel_firmware_decode.c', · line 75

Quoted 10 lines
tools/meson.build +5 -0
 	   install : true)
 
+executable('intel_gpu_frequency', 'intel_gpu_frequency.c',
+	   dependencies : [lib_igt_chipset, lib_igt_tools_stub, lib_igt_drm_stub],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#27 lore raw

PATCH v2 13/31 lib/i915/intel_decode: replace igt.h with minimal headers

In reply to Sebastian Brzezinka

intel_decode.c only uses two symbols from the IGT: intel_gen() and intel_get_device_info(), both provided by intel_chipset.h. The DRM_PRINTFLIKE macro used for the instr_out() format attribute is provided by xf86drm.h.

This is a prerequisite for building intel_decode.c into a static sub-library (lib_i915_decode) that tools can link without pulling in the full libigt.so stack.

---
 lib/i915/intel_decode.c | 4 ++--
 lib/meson.build         | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)
lib/i915/intel_decode.c +2 -2
index b78993c47..d4a4da4da 100644
@@ -28,8 +28,8 @@
 #include <stdbool.h>
 #include <stdarg.h>
 #include <string.h>
-
-#include "igt.h"
+#include <xf86drm.h>
+#include "intel_chipset.h"
 #include "intel_decode.h"
 
 /* Struct for tracking intel_decode state. */
lib/meson.build +3 -1
index 43ae4ce66..aa8eae68b 100644
@@ -432,7 +432,9 @@ lib_i915_decode_build = static_library('i915_decode',
 
 lib_i915_decode = declare_dependency(link_with : lib_i915_decode_build,
 				     dependencies : [lib_igt_chipset,
-				                     lib_igt_tools_stub],
+				                     lib_igt_tools_stub,
+				                     lib_igt_drm_stub,
+				                     pciaccess],
 				     include_directories : inc)
 
 lib_igt_reg_tools_build = static_library('igt_reg_tools',
Signature · 1 line
2.53.0
Reviewed-by on v2 13/31
#28 lore raw

Re: [PATCH i-g-t v2 13/31] lib/i915/intel_decode: replace igt.h with minimal headers

Quoted 21 lines · Sebastian Brzezinka

intel_decode.c only uses two symbols from the IGT: intel_gen() and intel_get_device_info(), both provided by intel_chipset.h. The DRM_PRINTFLIKE macro used for the instr_out() format attribute is provided by xf86drm.h.

This is a prerequisite for building intel_decode.c into a static sub-library (lib_i915_decode) that tools can link without pulling in the full libigt.so stack.

---
 lib/i915/intel_decode.c | 4 ++--
 lib/meson.build         | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)
lib/i915/intel_decode.c +0 -0
index b78993c47..d4a4da4da 100644

lib/i915/intel_decode.c line 34

Quoted 9 lines
lib/i915/intel_decode.c +2 -2
@@ -28,8 +28,8 @@
 #include <stdbool.h>
 #include <stdarg.h>
 #include <string.h>
-
-#include "igt.h"
+#include <xf86drm.h>
+#include "intel_chipset.h"
 #include "intel_decode.h"
 

Nit: shouldn't you use a newline between <> and "" includes?

Quoted 7 lines
lib/i915/intel_decode.c +0 -0
 /* Struct for tracking intel_decode state. */
lib/meson.build +0 -0
index 43ae4ce66..aa8eae68b 100644

lib/meson.build lib_i915_decode_build = static_library('i915_decode', · line 440

Quoted 10 lines
lib/meson.build +3 -1
@@ -432,7 +432,9 @@ lib_i915_decode_build = static_library('i915_decode',
 
 lib_i915_decode = declare_dependency(link_with : lib_i915_decode_build,
 				     dependencies : [lib_igt_chipset,
-				                     lib_igt_tools_stub],
+				                     lib_igt_tools_stub,
+				                     lib_igt_drm_stub,
+				                     pciaccess],
 				     include_directories : inc)
 
 lib_igt_reg_tools_build = static_library('igt_reg_tools',

With nitpick resolved:

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#29 lore raw

PATCH v2 14/31 tools/intel_stepping: link with minimal sub-libraries

In reply to Sebastian Brzezinka

intel_stepping only needs the chipset tables and the small tool stub support used by those helpers, not the full libigt.so stack.

Switch to linking against lib_igt_chipset, lib_igt_tools_stub and libpciaccess.

ldd before: 35 (ldd | wc -l)
ldd after: 4 (ldd | wc -l)

---
 tools/meson.build | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/meson.build +6 -1
index 01400f53e..8eb346321 100644
@@ -36,7 +36,6 @@ tools_progs = [
 	'intel_pm_rpm',
 	'intel_reg_checker',
 	'intel_residency',
-	'intel_stepping',
 	'intel_tiling_detect',
 	'intel_vbt_decode',
 	'intel_watermark',
@@ -70,6 +69,12 @@ executable('intel_gpu_frequency', 'intel_gpu_frequency.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)
 
+executable('intel_stepping', 'intel_stepping.c',
+	   dependencies : [lib_igt_chipset, lib_igt_tools_stub, lib_igt_drm_stub,
+	                    pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 14/31
#30 lore raw

Re: [PATCH i-g-t v2 14/31] tools/intel_stepping: link with minimal sub-libraries

Quoted 31 lines · Sebastian Brzezinka

intel_stepping only needs the chipset tables and the small tool stub support used by those helpers, not the full libigt.so stack.

Switch to linking against lib_igt_chipset, lib_igt_tools_stub and libpciaccess.

ldd before: 35 (ldd | wc -l)
ldd after: 4 (ldd | wc -l)

---
 tools/meson.build | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/meson.build +0 -1
index 01400f53e..8eb346321 100644
@@ -36,7 +36,6 @@ tools_progs = [
 	'intel_pm_rpm',
 	'intel_reg_checker',
 	'intel_residency',
-	'intel_stepping',
 	'intel_tiling_detect',
 	'intel_vbt_decode',
 	'intel_watermark',
@@ -70,6 +69,12 @@ executable('intel_gpu_frequency', 'intel_gpu_frequency.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)

tools/meson.build executable('intel_gpu_frequency', 'intel_gpu_frequency.c', · line 80

Quoted 10 lines
tools/meson.build +6 -0
 
+executable('intel_stepping', 'intel_stepping.c',
+	   dependencies : [lib_igt_chipset, lib_igt_tools_stub, lib_igt_drm_stub,
+	                    pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#31 lore raw

PATCH v2 15/31 tools/intel_gtt: link with minimal sub-libraries

In reply to Sebastian Brzezinka

intel_gtt only needs the chipset helpers plus the small tool stubs they rely on. The full libigt.so dependency chain is unnecessary.

Switch to linking against lib_igt_chipset, lib_igt_tools_stub, lib_igt_drm_stub, pciaccess and libdrm.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/meson.build +6 -1
index 8eb346321..a3fef87a9 100644
@@ -25,7 +25,6 @@ tools_progs = [
 	'intel_forcewaked',
 	'intel_framebuffer_dump',
 	'intel_gpu_time',
-	'intel_gtt',
 	'intel_guc_logger',
 	'intel_hdcp',
 	'intel_infoframes',
@@ -75,6 +74,12 @@ executable('intel_stepping', 'intel_stepping.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)
 
+executable('intel_gtt', 'intel_gtt.c',
+	   dependencies : [lib_igt_chipset, lib_igt_tools_stub, lib_igt_drm_stub,
+	                    pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 15/31
#32 lore raw

Re: [PATCH i-g-t v2 15/31] tools/intel_gtt: link with minimal sub-libraries

Quoted 31 lines · Sebastian Brzezinka

intel_gtt only needs the chipset helpers plus the small tool stubs they rely on. The full libigt.so dependency chain is unnecessary.

Switch to linking against lib_igt_chipset, lib_igt_tools_stub, lib_igt_drm_stub, pciaccess and libdrm.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/meson.build +0 -1
index 8eb346321..a3fef87a9 100644
@@ -25,7 +25,6 @@ tools_progs = [
 	'intel_forcewaked',
 	'intel_framebuffer_dump',
 	'intel_gpu_time',
-	'intel_gtt',
 	'intel_guc_logger',
 	'intel_hdcp',
 	'intel_infoframes',
@@ -75,6 +74,12 @@ executable('intel_stepping', 'intel_stepping.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)

tools/meson.build executable('intel_stepping', 'intel_stepping.c', · line 85

Quoted 10 lines
tools/meson.build +6 -0
 
+executable('intel_gtt', 'intel_gtt.c',
+	   dependencies : [lib_igt_chipset, lib_igt_tools_stub, lib_igt_drm_stub,
+	                    pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#33 lore raw

PATCH v2 16/31 tools/intel_dump_decode: link with minimal sub-libraries

In reply to Sebastian Brzezinka

intel_dump_decode only needs the i915 decoder. Link it against lib_i915_decode instead of the full libigt.so stack.

ldd before: 35 (ldd | wc -l)
ldd after: 4 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
index a3fef87a9..467b8eea1 100644
@@ -20,7 +20,6 @@ tools_progs = [
 	'intel_display_bandwidth',
 	'intel_display_crc',
 	'intel_display_poller',
-	'intel_dump_decode',
 	'intel_error_decode',
 	'intel_forcewaked',
 	'intel_framebuffer_dump',
@@ -80,6 +79,11 @@ executable('intel_gtt', 'intel_gtt.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)
 
+executable('intel_dump_decode', 'intel_dump_decode.c',
+	   dependencies : [lib_i915_decode],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 16/31
#34 lore raw

Re: [PATCH i-g-t v2 16/31] tools/intel_dump_decode: link with minimal sub-libraries

Quoted 27 lines · Sebastian Brzezinka

intel_dump_decode only needs the i915 decoder. Link it against lib_i915_decode instead of the full libigt.so stack.

ldd before: 35 (ldd | wc -l)
ldd after: 4 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +0 -1
index a3fef87a9..467b8eea1 100644
@@ -20,7 +20,6 @@ tools_progs = [
 	'intel_display_bandwidth',
 	'intel_display_crc',
 	'intel_display_poller',
-	'intel_dump_decode',
 	'intel_error_decode',
 	'intel_forcewaked',
 	'intel_framebuffer_dump',
@@ -80,6 +79,11 @@ executable('intel_gtt', 'intel_gtt.c',
 	   install_rpath : bindir_rpathdir,

tools/meson.build executable('intel_gtt', 'intel_gtt.c', · line 89

Quoted 10 lines
tools/meson.build +5 -0
 	   install : true)
 
+executable('intel_dump_decode', 'intel_dump_decode.c',
+	   dependencies : [lib_i915_decode],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#35 lore raw

PATCH v2 17/31 tools/intel_error_decode: link with minimal sub-libraries

In reply to Sebastian Brzezinka

intel_error_decode needs the batch decoder, chipset tables and zlib for compressed error state handling, but not the full libigt.so stack.

Switch to linking against lib_i915_decode plus the minimal helper libraries it relies on.

ldd before: 35 (ldd | wc -l)
ldd after: 4 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
index 467b8eea1..b04754c5e 100644
@@ -20,7 +20,6 @@ tools_progs = [
 	'intel_display_bandwidth',
 	'intel_display_crc',
 	'intel_display_poller',
-	'intel_error_decode',
 	'intel_forcewaked',
 	'intel_framebuffer_dump',
 	'intel_gpu_time',
@@ -84,6 +83,11 @@ executable('intel_dump_decode', 'intel_dump_decode.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)
 
+executable('intel_error_decode', 'intel_error_decode.c',
+	   dependencies : [lib_i915_decode, pciaccess, zlib, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 17/31
#36 lore raw

Re: [PATCH i-g-t v2 17/31] tools/intel_error_decode: link with minimal sub-libraries

Quoted 30 lines · Sebastian Brzezinka

intel_error_decode needs the batch decoder, chipset tables and zlib for compressed error state handling, but not the full libigt.so stack.

Switch to linking against lib_i915_decode plus the minimal helper libraries it relies on.

ldd before: 35 (ldd | wc -l)
ldd after: 4 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +0 -1
index 467b8eea1..b04754c5e 100644
@@ -20,7 +20,6 @@ tools_progs = [
 	'intel_display_bandwidth',
 	'intel_display_crc',
 	'intel_display_poller',
-	'intel_error_decode',
 	'intel_forcewaked',
 	'intel_framebuffer_dump',
 	'intel_gpu_time',
@@ -84,6 +83,11 @@ executable('intel_dump_decode', 'intel_dump_decode.c',
 	   install_rpath : bindir_rpathdir,

tools/meson.build executable('intel_dump_decode', 'intel_dump_decode.c', · line 93

Quoted 10 lines
tools/meson.build +5 -0
 	   install : true)
 
+executable('intel_error_decode', 'intel_error_decode.c',
+	   dependencies : [lib_i915_decode, pciaccess, zlib, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#37 lore raw

PATCH v2 18/31 tools/intel_vbt_decode: link with minimal sub-libraries

In reply to Sebastian Brzezinka

intel_vbt_decode only needs the chipset tables, half-float conversion helpers and the lightweight tool stubs used by those helpers.

Switch to linking against lib_igt_chipset, lib_igt_halffloat and lib_igt_tools_stub instead of the full libigt.so stack.

ldd before: 35 (ldd | wc -l)
ldd after: 4 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
index b04754c5e..46cf1a717 100644
@@ -34,7 +34,6 @@ tools_progs = [
 	'intel_reg_checker',
 	'intel_residency',
 	'intel_tiling_detect',
-	'intel_vbt_decode',
 	'intel_watermark',
 	'intel_gem_info',
 	'intel_gvtg_test',
@@ -88,6 +87,11 @@ executable('intel_error_decode', 'intel_error_decode.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)
 
+executable('intel_vbt_decode', 'intel_vbt_decode.c',
+	   dependencies : [lib_igt_chipset, lib_igt_halffloat, lib_igt_tools_stub, pciaccess, libdrm, math],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 18/31
#38 lore raw

Re: [PATCH i-g-t v2 18/31] tools/intel_vbt_decode: link with minimal sub-libraries

Quoted 30 lines · Sebastian Brzezinka

intel_vbt_decode only needs the chipset tables, half-float conversion helpers and the lightweight tool stubs used by those helpers.

Switch to linking against lib_igt_chipset, lib_igt_halffloat and lib_igt_tools_stub instead of the full libigt.so stack.

ldd before: 35 (ldd | wc -l)
ldd after: 4 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +0 -1
index b04754c5e..46cf1a717 100644
@@ -34,7 +34,6 @@ tools_progs = [
 	'intel_reg_checker',
 	'intel_residency',
 	'intel_tiling_detect',
-	'intel_vbt_decode',
 	'intel_watermark',
 	'intel_gem_info',
 	'intel_gvtg_test',
@@ -88,6 +87,11 @@ executable('intel_error_decode', 'intel_error_decode.c',
 	   install_rpath : bindir_rpathdir,

tools/meson.build executable('intel_error_decode', 'intel_error_decode.c', · line 97

Quoted 10 lines
tools/meson.build +5 -0
 	   install : true)
 
+executable('intel_vbt_decode', 'intel_vbt_decode.c',
+	   dependencies : [lib_igt_chipset, lib_igt_halffloat, lib_igt_tools_stub, pciaccess, libdrm, math],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#39 lore raw

PATCH v2 19/31 tools/intel_backlight: link with minimal sub-libraries

In reply to Sebastian Brzezinka

intel_backlight only needs MMIO/register access helpers and the chipset metadata they use. The full libigt.so stack is unnecessary.

Add lib_igt_reg_tools and link intel_backlight against it instead of libigt.so.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
index 46cf1a717..8899a5b49 100644
@@ -15,7 +15,6 @@ tools_progs = [
 	'igt_facts',
 	'igt_power',
 	'intel_audio_dump',
-	'intel_backlight',
 	'intel_bios_dumper',
 	'intel_display_bandwidth',
 	'intel_display_crc',
@@ -92,6 +91,11 @@ executable('intel_vbt_decode', 'intel_vbt_decode.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)
 
+executable('intel_backlight', 'intel_backlight.c',
+	   dependencies : [lib_igt_reg_tools, pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 19/31
#40 lore raw

Re: [PATCH i-g-t v2 19/31] tools/intel_backlight: link with minimal sub-libraries

Quoted 30 lines · Sebastian Brzezinka

intel_backlight only needs MMIO/register access helpers and the chipset metadata they use. The full libigt.so stack is unnecessary.

Add lib_igt_reg_tools and link intel_backlight against it instead of libigt.so.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +0 -1
index 46cf1a717..8899a5b49 100644
@@ -15,7 +15,6 @@ tools_progs = [
 	'igt_facts',
 	'igt_power',
 	'intel_audio_dump',
-	'intel_backlight',
 	'intel_bios_dumper',
 	'intel_display_bandwidth',
 	'intel_display_crc',
@@ -92,6 +91,11 @@ executable('intel_vbt_decode', 'intel_vbt_decode.c',
 	   install_rpath : bindir_rpathdir,

tools/meson.build executable('intel_vbt_decode', 'intel_vbt_decode.c', · line 101

Quoted 10 lines
tools/meson.build +5 -0
 	   install : true)
 
+executable('intel_backlight', 'intel_backlight.c',
+	   dependencies : [lib_igt_reg_tools, pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#41 lore raw

PATCH v2 20/31 tools/intel_lid: link with minimal sub-libraries

In reply to Sebastian Brzezinka

intel_lid only needs the register/MMIO helper subset, not the full libigt.so stack.

Switch to linking against lib_igt_reg_tools.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
index 8899a5b49..0978f8f11 100644
@@ -25,7 +25,6 @@ tools_progs = [
 	'intel_guc_logger',
 	'intel_hdcp',
 	'intel_infoframes',
-	'intel_lid',
 	'intel_opregion_decode',
 	'intel_panel_fitter',
 	'intel_perf_counters',
@@ -96,6 +95,11 @@ executable('intel_backlight', 'intel_backlight.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)
 
+executable('intel_lid', 'intel_lid.c',
+	   dependencies : [lib_igt_reg_tools, pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 20/31
#42 lore raw

Re: [PATCH i-g-t v2 20/31] tools/intel_lid: link with minimal sub-libraries

Quoted 29 lines · Sebastian Brzezinka

intel_lid only needs the register/MMIO helper subset, not the full libigt.so stack.

Switch to linking against lib_igt_reg_tools.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +0 -1
index 8899a5b49..0978f8f11 100644
@@ -25,7 +25,6 @@ tools_progs = [
 	'intel_guc_logger',
 	'intel_hdcp',
 	'intel_infoframes',
-	'intel_lid',
 	'intel_opregion_decode',
 	'intel_panel_fitter',
 	'intel_perf_counters',
@@ -96,6 +95,11 @@ executable('intel_backlight', 'intel_backlight.c',
 	   install_rpath : bindir_rpathdir,

tools/meson.build executable('intel_backlight', 'intel_backlight.c', · line 105

Quoted 10 lines
tools/meson.build +5 -0
 	   install : true)
 
+executable('intel_lid', 'intel_lid.c',
+	   dependencies : [lib_igt_reg_tools, pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#43 lore raw

PATCH v2 21/31 tools/intel_gpu_time: link with minimal sub-libraries

In reply to Sebastian Brzezinka

intel_gpu_time only needs the register/MMIO helper subset, not the full libigt.so stack.

Switch to linking against lib_igt_reg_tools.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
index 0978f8f11..2e8ceea36 100644
@@ -21,7 +21,6 @@ tools_progs = [
 	'intel_display_poller',
 	'intel_forcewaked',
 	'intel_framebuffer_dump',
-	'intel_gpu_time',
 	'intel_guc_logger',
 	'intel_hdcp',
 	'intel_infoframes',
@@ -100,6 +99,11 @@ executable('intel_lid', 'intel_lid.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)
 
+executable('intel_gpu_time', 'intel_gpu_time.c',
+	   dependencies : [lib_igt_reg_tools, pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 21/31
#44 lore raw

Re: [PATCH i-g-t v2 21/31] tools/intel_gpu_time: link with minimal sub-libraries

Quoted 29 lines · Sebastian Brzezinka

intel_gpu_time only needs the register/MMIO helper subset, not the full libigt.so stack.

Switch to linking against lib_igt_reg_tools.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +0 -1
index 0978f8f11..2e8ceea36 100644
@@ -21,7 +21,6 @@ tools_progs = [
 	'intel_display_poller',
 	'intel_forcewaked',
 	'intel_framebuffer_dump',
-	'intel_gpu_time',
 	'intel_guc_logger',
 	'intel_hdcp',
 	'intel_infoframes',
@@ -100,6 +99,11 @@ executable('intel_lid', 'intel_lid.c',
 	   install_rpath : bindir_rpathdir,

tools/meson.build executable('intel_lid', 'intel_lid.c', · line 109

Quoted 10 lines
tools/meson.build +5 -0
 	   install : true)
 
+executable('intel_gpu_time', 'intel_gpu_time.c',
+	   dependencies : [lib_igt_reg_tools, pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#45 lore raw

PATCH v2 22/31 tools/intel_audio_dump: link with minimal sub-libraries

In reply to Sebastian Brzezinka

intel_audio_dump only needs the register/MMIO helper subset, not the full libigt.so stack.

Switch to linking against lib_igt_reg_tools.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
index 2e8ceea36..f9bbb41a9 100644
@@ -14,7 +14,6 @@ endforeach
 tools_progs = [
 	'igt_facts',
 	'igt_power',
-	'intel_audio_dump',
 	'intel_bios_dumper',
 	'intel_display_bandwidth',
 	'intel_display_crc',
@@ -104,6 +103,11 @@ executable('intel_gpu_time', 'intel_gpu_time.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)
 
+executable('intel_audio_dump', 'intel_audio_dump.c',
+	   dependencies : [lib_igt_reg_tools, pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 22/31
#46 lore raw

Re: [PATCH i-g-t v2 22/31] tools/intel_audio_dump: link with minimal sub-libraries

Quoted 29 lines · Sebastian Brzezinka

intel_audio_dump only needs the register/MMIO helper subset, not the full libigt.so stack.

Switch to linking against lib_igt_reg_tools.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +0 -1
index 2e8ceea36..f9bbb41a9 100644
@@ -14,7 +14,6 @@ endforeach
 tools_progs = [
 	'igt_facts',
 	'igt_power',
-	'intel_audio_dump',
 	'intel_bios_dumper',
 	'intel_display_bandwidth',
 	'intel_display_crc',
@@ -104,6 +103,11 @@ executable('intel_gpu_time', 'intel_gpu_time.c',
 	   install_rpath : bindir_rpathdir,

tools/meson.build executable('intel_gpu_time', 'intel_gpu_time.c', · line 113

Quoted 10 lines
tools/meson.build +5 -0
 	   install : true)
 
+executable('intel_audio_dump', 'intel_audio_dump.c',
+	   dependencies : [lib_igt_reg_tools, pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#47 lore raw

PATCH v2 23/31 tools/intel_forcewaked: link with minimal sub-libraries

In reply to Sebastian Brzezinka

intel_forcewaked only needs the register/MMIO helper subset, not the full libigt.so stack.

Switch to linking against lib_igt_reg_tools.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
index f9bbb41a9..15bd40dec 100644
@@ -18,7 +18,6 @@ tools_progs = [
 	'intel_display_bandwidth',
 	'intel_display_crc',
 	'intel_display_poller',
-	'intel_forcewaked',
 	'intel_framebuffer_dump',
 	'intel_guc_logger',
 	'intel_hdcp',
@@ -108,6 +107,11 @@ executable('intel_audio_dump', 'intel_audio_dump.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)
 
+executable('intel_forcewaked', 'intel_forcewaked.c',
+	   dependencies : [lib_igt_reg_tools, pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 23/31
#48 lore raw

Re: [PATCH i-g-t v2 23/31] tools/intel_forcewaked: link with minimal sub-libraries

Quoted 29 lines · Sebastian Brzezinka

intel_forcewaked only needs the register/MMIO helper subset, not the full libigt.so stack.

Switch to linking against lib_igt_reg_tools.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +0 -1
index f9bbb41a9..15bd40dec 100644
@@ -18,7 +18,6 @@ tools_progs = [
 	'intel_display_bandwidth',
 	'intel_display_crc',
 	'intel_display_poller',
-	'intel_forcewaked',
 	'intel_framebuffer_dump',
 	'intel_guc_logger',
 	'intel_hdcp',
@@ -108,6 +107,11 @@ executable('intel_audio_dump', 'intel_audio_dump.c',
 	   install_rpath : bindir_rpathdir,

tools/meson.build executable('intel_audio_dump', 'intel_audio_dump.c', · line 117

Quoted 10 lines
tools/meson.build +5 -0
 	   install : true)
 
+executable('intel_forcewaked', 'intel_forcewaked.c',
+	   dependencies : [lib_igt_reg_tools, pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#49 lore raw

PATCH v2 24/31 tools/intel_guc_logger: link with minimal sub-libraries

In reply to Sebastian Brzezinka

intel_guc_logger only needs core logging/assert helpers and debugfs access, not the full libigt.so stack. Replace the monolithic include with the minimal headers and link against lib_igt_tools_stub.

The tool previously used igt_simple_main_args() for option parsing, which is part of libigt.so and cannot be used without it. Replace it with a direct getopt_long() loop. As part of this: add a 'help' long option, a usage string header, and a default case that calls exit(1) on unrecognised options, behaviour that igt_simple_main_args() provided implicitly.

ldd before: 35 (ldd | wc -l)
ldd after: 3 (ldd | wc -l)

---
 tools/intel_guc_logger.c | 21 ++++++++++++++++++---
 tools/meson.build        |  6 +++++-
 2 files changed, 23 insertions(+), 4 deletions(-)
tools/intel_guc_logger.c +18 -3
index 629b4e660..3990aef87 100644
@@ -38,9 +38,12 @@
 #include <sys/syscall.h>
 #include <sys/mman.h>
 #include <assert.h>
+#include <getopt.h>
 #include <pthread.h>
 
-#include "igt.h"
+#include "drmtest.h"
+#include "igt_core.h"
+#include "igt_debugfs.h"
 
 #define MB(x) ((uint64_t)(x) * 1024 * 1024)
 #ifndef PAGE_SIZE
@@ -367,6 +370,8 @@ static int parse_options(int opt, int opt_index, void *data)
 		discard_oldlogs = true;
 		igt_debug("old/boot-time logs will be discarded\n");
 		break;
+	default:
+		exit(1);
 	}
 
 	return 0;
@@ -382,10 +387,12 @@ static void process_command_line(int argc, char **argv)
 		{"polltimeout", required_argument, 0, 'p'},
 		{"size", required_argument, 0, 's'},
 		{"discard", no_argument, 0, 'd'},
+		{"help", no_argument, 0, 'h'},
 		{ 0, 0, 0, 0 }
 	};
 
 	const char *help =
+		"Usage: intel_guc_logger [options]\n"
 		"  -v --verbosity=level   verbosity level of GuC logging (0-3)\n"
 		"  -o --outputfile=name   name of the output file, including the location, where logs will be stored\n"
 		"  -b --buffers=num       number of buffers to be maintained on logger side for storing logs\n"
@@ -394,8 +401,16 @@ static void process_command_line(int argc, char **argv)
 		"  -s --size=MB           max size of output file in MBs after which logging will be stopped\n"
 		"  -d --discard           discard the old/boot-time logs before entering into the capture loop\n";
 
-	igt_simple_init_parse_opts(&argc, argv, "v:o:b:t:p:s:d", long_options,
-				   help, parse_options, NULL);
+	int opt, opt_index = 0;
+
+	while ((opt = getopt_long(argc, argv, "v:o:b:t:p:s:dh",
+				  long_options, &opt_index)) != -1) {
+		if (opt == 'h') {
+			printf("%s", help);
+			exit(0);
+		}
+		parse_options(opt, opt_index, NULL);
+	}
 }
 
 int main(int argc, char **argv)
tools/meson.build +5 -1
index 15bd40dec..32a345e9d 100644
@@ -19,7 +19,6 @@ tools_progs = [
 	'intel_display_crc',
 	'intel_display_poller',
 	'intel_framebuffer_dump',
-	'intel_guc_logger',
 	'intel_hdcp',
 	'intel_infoframes',
 	'intel_opregion_decode',
@@ -112,6 +111,11 @@ executable('intel_forcewaked', 'intel_forcewaked.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)
 
+executable('intel_guc_logger', 'intel_guc_logger.c',
+	   dependencies : [lib_igt_tools_stub, libdrm, pthreads],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 24/31
#50 lore raw

Re: [PATCH i-g-t v2 24/31] tools/intel_guc_logger: link with minimal sub-libraries

Quoted 94 lines · Sebastian Brzezinka

intel_guc_logger only needs core logging/assert helpers and debugfs access, not the full libigt.so stack. Replace the monolithic include with the minimal headers and link against lib_igt_tools_stub.

The tool previously used igt_simple_main_args() for option parsing, which is part of libigt.so and cannot be used without it. Replace it with a direct getopt_long() loop. As part of this: add a 'help' long option, a usage string header, and a default case that calls exit(1) on unrecognised options, behaviour that igt_simple_main_args() provided implicitly.

ldd before: 35 (ldd | wc -l)
ldd after: 3 (ldd | wc -l)

---
 tools/intel_guc_logger.c | 21 ++++++++++++++++++---
 tools/meson.build        |  6 +++++-
 2 files changed, 23 insertions(+), 4 deletions(-)
tools/intel_guc_logger.c +18 -3
index 629b4e660..3990aef87 100644
@@ -38,9 +38,12 @@
 #include <sys/syscall.h>
 #include <sys/mman.h>
 #include <assert.h>
+#include <getopt.h>
 #include <pthread.h>
 
-#include "igt.h"
+#include "drmtest.h"
+#include "igt_core.h"
+#include "igt_debugfs.h"
 
 #define MB(x) ((uint64_t)(x) * 1024 * 1024)
 #ifndef PAGE_SIZE
@@ -367,6 +370,8 @@ static int parse_options(int opt, int opt_index, void *data)
 		discard_oldlogs = true;
 		igt_debug("old/boot-time logs will be discarded\n");
 		break;
+	default:
+		exit(1);
 	}
 
 	return 0;
@@ -382,10 +387,12 @@ static void process_command_line(int argc, char **argv)
 		{"polltimeout", required_argument, 0, 'p'},
 		{"size", required_argument, 0, 's'},
 		{"discard", no_argument, 0, 'd'},
+		{"help", no_argument, 0, 'h'},
 		{ 0, 0, 0, 0 }
 	};
 
 	const char *help =
+		"Usage: intel_guc_logger [options]\n"
 		"  -v --verbosity=level   verbosity level of GuC logging (0-3)\n"
 		"  -o --outputfile=name   name of the output file, including the location, where logs will be stored\n"
 		"  -b --buffers=num       number of buffers to be maintained on logger side for storing logs\n"
@@ -394,8 +401,16 @@ static void process_command_line(int argc, char **argv)
 		"  -s --size=MB           max size of output file in MBs after which logging will be stopped\n"
 		"  -d --discard           discard the old/boot-time logs before entering into the capture loop\n";
 
-	igt_simple_init_parse_opts(&argc, argv, "v:o:b:t:p:s:d", long_options,
-				   help, parse_options, NULL);
+	int opt, opt_index = 0;
+
+	while ((opt = getopt_long(argc, argv, "v:o:b:t:p:s:dh",
+				  long_options, &opt_index)) != -1) {
+		if (opt == 'h') {
+			printf("%s", help);
+			exit(0);
+		}
+		parse_options(opt, opt_index, NULL);
+	}
 }
 
 int main(int argc, char **argv)
tools/meson.build +0 -1
index 15bd40dec..32a345e9d 100644
@@ -19,7 +19,6 @@ tools_progs = [
 	'intel_display_crc',
 	'intel_display_poller',
 	'intel_framebuffer_dump',
-	'intel_guc_logger',
 	'intel_hdcp',
 	'intel_infoframes',
 	'intel_opregion_decode',
@@ -112,6 +111,11 @@ executable('intel_forcewaked', 'intel_forcewaked.c',
 	   install_rpath : bindir_rpathdir,

tools/meson.build executable('intel_forcewaked', 'intel_forcewaked.c', · line 121

Quoted 10 lines
tools/meson.build +5 -0
 	   install : true)
 
+executable('intel_guc_logger', 'intel_guc_logger.c',
+	   dependencies : [lib_igt_tools_stub, libdrm, pthreads],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#51 lore raw

PATCH v2 25/31 tools/intel_infoframes: link with minimal sub-libraries

In reply to Sebastian Brzezinka

intel_infoframes only needs the register/MMIO helper subset, not the full libigt.so stack.

Switch to linking against lib_igt_reg_tools.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
index 32a345e9d..a31b6d0ed 100644
@@ -20,7 +20,6 @@ tools_progs = [
 	'intel_display_poller',
 	'intel_framebuffer_dump',
 	'intel_hdcp',
-	'intel_infoframes',
 	'intel_opregion_decode',
 	'intel_panel_fitter',
 	'intel_perf_counters',
@@ -116,6 +115,11 @@ executable('intel_guc_logger', 'intel_guc_logger.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)
 
+executable('intel_infoframes', 'intel_infoframes.c',
+	   dependencies : [lib_igt_reg_tools, pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 25/31
#52 lore raw

Re: [PATCH i-g-t v2 25/31] tools/intel_infoframes: link with minimal sub-libraries

Quoted 29 lines · Sebastian Brzezinka

intel_infoframes only needs the register/MMIO helper subset, not the full libigt.so stack.

Switch to linking against lib_igt_reg_tools.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +0 -1
index 32a345e9d..a31b6d0ed 100644
@@ -20,7 +20,6 @@ tools_progs = [
 	'intel_display_poller',
 	'intel_framebuffer_dump',
 	'intel_hdcp',
-	'intel_infoframes',
 	'intel_opregion_decode',
 	'intel_panel_fitter',
 	'intel_perf_counters',
@@ -116,6 +115,11 @@ executable('intel_guc_logger', 'intel_guc_logger.c',
 	   install_rpath : bindir_rpathdir,

tools/meson.build executable('intel_guc_logger', 'intel_guc_logger.c', · line 125

Quoted 10 lines
tools/meson.build +5 -0
 	   install : true)
 
+executable('intel_infoframes', 'intel_infoframes.c',
+	   dependencies : [lib_igt_reg_tools, pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#53 lore raw

PATCH v2 26/31 tools/intel_panel_fitter: link with minimal sub-libraries

In reply to Sebastian Brzezinka

intel_panel_fitter only needs the register/MMIO helper subset, not the full libigt.so stack.

Switch to linking against lib_igt_reg_tools.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
index a31b6d0ed..1a4e14ed3 100644
@@ -21,7 +21,6 @@ tools_progs = [
 	'intel_framebuffer_dump',
 	'intel_hdcp',
 	'intel_opregion_decode',
-	'intel_panel_fitter',
 	'intel_perf_counters',
 	'intel_pm_rpm',
 	'intel_reg_checker',
@@ -120,6 +119,11 @@ executable('intel_infoframes', 'intel_infoframes.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)
 
+executable('intel_panel_fitter', 'intel_panel_fitter.c',
+	   dependencies : [lib_igt_reg_tools, pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 26/31
#54 lore raw

Re: [PATCH i-g-t v2 26/31] tools/intel_panel_fitter: link with minimal sub-libraries

Quoted 29 lines · Sebastian Brzezinka

intel_panel_fitter only needs the register/MMIO helper subset, not the full libigt.so stack.

Switch to linking against lib_igt_reg_tools.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +0 -1
index a31b6d0ed..1a4e14ed3 100644
@@ -21,7 +21,6 @@ tools_progs = [
 	'intel_framebuffer_dump',
 	'intel_hdcp',
 	'intel_opregion_decode',
-	'intel_panel_fitter',
 	'intel_perf_counters',
 	'intel_pm_rpm',
 	'intel_reg_checker',
@@ -120,6 +119,11 @@ executable('intel_infoframes', 'intel_infoframes.c',
 	   install_rpath : bindir_rpathdir,

tools/meson.build executable('intel_infoframes', 'intel_infoframes.c', · line 129

Quoted 10 lines
tools/meson.build +5 -0
 	   install : true)
 
+executable('intel_panel_fitter', 'intel_panel_fitter.c',
+	   dependencies : [lib_igt_reg_tools, pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#55 lore raw

PATCH v2 27/31 tools/intel_watermark: link with minimal sub-libraries

In reply to Sebastian Brzezinka

intel_watermark only needs the register/MMIO helper subset, not the full libigt.so stack.

Switch to linking against lib_igt_reg_tools.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
index 1a4e14ed3..0cc62b54d 100644
@@ -26,7 +26,6 @@ tools_progs = [
 	'intel_reg_checker',
 	'intel_residency',
 	'intel_tiling_detect',
-	'intel_watermark',
 	'intel_gem_info',
 	'intel_gvtg_test',
 	'dpcd_reg',
@@ -124,6 +123,11 @@ executable('intel_panel_fitter', 'intel_panel_fitter.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)
 
+executable('intel_watermark', 'intel_watermark.c',
+	   dependencies : [lib_igt_reg_tools, pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 27/31
#56 lore raw

Re: [PATCH i-g-t v2 27/31] tools/intel_watermark: link with minimal sub-libraries

Quoted 29 lines · Sebastian Brzezinka

intel_watermark only needs the register/MMIO helper subset, not the full libigt.so stack.

Switch to linking against lib_igt_reg_tools.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +0 -1
index 1a4e14ed3..0cc62b54d 100644
@@ -26,7 +26,6 @@ tools_progs = [
 	'intel_reg_checker',
 	'intel_residency',
 	'intel_tiling_detect',
-	'intel_watermark',
 	'intel_gem_info',
 	'intel_gvtg_test',
 	'dpcd_reg',
@@ -124,6 +123,11 @@ executable('intel_panel_fitter', 'intel_panel_fitter.c',
 	   install_rpath : bindir_rpathdir,

tools/meson.build executable('intel_panel_fitter', 'intel_panel_fitter.c', · line 133

Quoted 10 lines
tools/meson.build +5 -0
 	   install : true)
 
+executable('intel_watermark', 'intel_watermark.c',
+	   dependencies : [lib_igt_reg_tools, pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#57 lore raw

PATCH v2 28/31 tools/intel_display_poller: link with minimal sub-libraries

In reply to Sebastian Brzezinka

intel_display_poller only needs the register/MMIO helper subset, not the full libigt.so stack.

Switch to linking against lib_igt_reg_tools.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
index 0cc62b54d..2a084a0c4 100644
@@ -17,7 +17,6 @@ tools_progs = [
 	'intel_bios_dumper',
 	'intel_display_bandwidth',
 	'intel_display_crc',
-	'intel_display_poller',
 	'intel_framebuffer_dump',
 	'intel_hdcp',
 	'intel_opregion_decode',
@@ -128,6 +127,11 @@ executable('intel_watermark', 'intel_watermark.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)
 
+executable('intel_display_poller', 'intel_display_poller.c',
+	   dependencies : [lib_igt_reg_tools, pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 28/31
#58 lore raw

Re: [PATCH i-g-t v2 28/31] tools/intel_display_poller: link with minimal sub-libraries

Quoted 29 lines · Sebastian Brzezinka

intel_display_poller only needs the register/MMIO helper subset, not the full libigt.so stack.

Switch to linking against lib_igt_reg_tools.

ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)

---
 tools/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +0 -1
index 0cc62b54d..2a084a0c4 100644
@@ -17,7 +17,6 @@ tools_progs = [
 	'intel_bios_dumper',
 	'intel_display_bandwidth',
 	'intel_display_crc',
-	'intel_display_poller',
 	'intel_framebuffer_dump',
 	'intel_hdcp',
 	'intel_opregion_decode',
@@ -128,6 +127,11 @@ executable('intel_watermark', 'intel_watermark.c',
 	   install_rpath : bindir_rpathdir,

tools/meson.build executable('intel_watermark', 'intel_watermark.c', · line 137

Quoted 10 lines
tools/meson.build +5 -0
 	   install : true)
 
+executable('intel_display_poller', 'intel_display_poller.c',
+	   dependencies : [lib_igt_reg_tools, pciaccess, libdrm],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#59 lore raw

PATCH v2 29/31 tools/intel_gvtg_test: link with minimal sub-libraries

In reply to Sebastian Brzezinka

intel_gvtg_test only needs the core assert/log/skip helpers provided by igt_core plus the lightweight tool stubs. Replace the monolithic include with the minimal header set and stop linking against libigt.so.

ldd before: 35 (ldd | wc -l)
ldd after: 3 (ldd | wc -l)

---
 tools/intel_gvtg_test.c | 2 +-
 tools/meson.build       | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)
tools/intel_gvtg_test.c +1 -1
index 408e703bf..fe8f7a599 100644
@@ -30,7 +30,7 @@
  */
 #include "config.h"
 
-#include "igt.h"
+#include "igt_core.h"
 #include <errno.h>
 #include <getopt.h>
 #include <math.h>
tools/meson.build +5 -1
index 2a084a0c4..6e694164f 100644
@@ -26,7 +26,6 @@ tools_progs = [
 	'intel_residency',
 	'intel_tiling_detect',
 	'intel_gem_info',
-	'intel_gvtg_test',
 	'dpcd_reg',
 	'lsgpu',
 ]
@@ -132,6 +131,11 @@ executable('intel_display_poller', 'intel_display_poller.c',
 	   install_rpath : bindir_rpathdir,
 	   install : true)
 
+executable('intel_gvtg_test', 'intel_gvtg_test.c',
+	   dependencies : [lib_igt_tools_stub, pciaccess, libdrm, math],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Reviewed-by on v2 29/31
#60 lore raw

Re: [PATCH i-g-t v2 29/31] tools/intel_gvtg_test: link with minimal sub-libraries

Quoted 42 lines · Sebastian Brzezinka

intel_gvtg_test only needs the core assert/log/skip helpers provided by igt_core plus the lightweight tool stubs. Replace the monolithic include with the minimal header set and stop linking against libigt.so.

ldd before: 35 (ldd | wc -l)
ldd after: 3 (ldd | wc -l)

---
 tools/intel_gvtg_test.c | 2 +-
 tools/meson.build       | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)
tools/intel_gvtg_test.c +1 -1
index 408e703bf..fe8f7a599 100644
@@ -30,7 +30,7 @@
  */
 #include "config.h"
 
-#include "igt.h"
+#include "igt_core.h"
 #include <errno.h>
 #include <getopt.h>
 #include <math.h>
tools/meson.build +0 -1
index 2a084a0c4..6e694164f 100644
@@ -26,7 +26,6 @@ tools_progs = [
 	'intel_residency',
 	'intel_tiling_detect',
 	'intel_gem_info',
-	'intel_gvtg_test',
 	'dpcd_reg',
 	'lsgpu',
 ]
@@ -132,6 +131,11 @@ executable('intel_display_poller', 'intel_display_poller.c',
 	   install_rpath : bindir_rpathdir,

tools/meson.build executable('intel_display_poller', 'intel_display_poller.c', · line 141

Quoted 10 lines
tools/meson.build +5 -0
 	   install : true)
 
+executable('intel_gvtg_test', 'intel_gvtg_test.c',
+	   dependencies : [lib_igt_tools_stub, pciaccess, libdrm, math],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 if libudev.found()
 	intel_dp_compliance_src = [
 		'intel_dp_compliance.c',

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#61 lore raw

PATCH v2 30/31 lib/igt_core: move igt_load_igtrc to igt_device_scan

In reply to Sebastian Brzezinka

igt_load_igtrc() is used exclusively by igt_device_scan internals to read per-device configuration from the igtrc file. Moving it from igt_core.c to igt_device_scan.c co-locates the function with its primary user and makes it possible for lsgpu to link against lib_igt_device_scan without needing the rest of libigt.

Update the declaration accordingly: remove from igt_core.h and add to igt_device_scan.h where the implementation now lives.

---
 lib/igt_core.c        | 47 ------------------------------------------
 lib/igt_core.h        |  2 --
 lib/igt_device_scan.c | 48 +++++++++++++++++++++++++++++++++++++++++++
 lib/igt_device_scan.h |  2 ++
 4 files changed, 50 insertions(+), 49 deletions(-)
lib/igt_core.c +0 -47
index a7c097d9e..2f737b01a 100644
@@ -972,53 +972,6 @@ static void oom_adjust_for_doom(void)
 
 }
 
-/**
- * load_igtrc:
- *
- * Load .igtrc from the path pointed to by #IGT_CONFIG_PATH or from
- * home directory if that is not set. The returned keyfile needs to be
- * deallocated using g_key_file_free().
- *
- * Returns: Pointer to the keyfile, NULL on error.
- */
-GKeyFile *igt_load_igtrc(void)
-{
-	char *key_file_env = NULL;
-	char *key_file_loc = NULL;
-	GError *error = NULL;
-	GKeyFile *file;
-	int ret;
-
-	/* Determine igt config path */
-	key_file_env = getenv("IGT_CONFIG_PATH");
-	if (key_file_env) {
-		key_file_loc = key_file_env;
-	} else {
-		key_file_loc = malloc(100);
-		snprintf(key_file_loc, 100, "%s/.igtrc", g_get_home_dir());
-	}
-
-	/* Load igt config file */
-	file = g_key_file_new();
-	ret = g_key_file_load_from_file(file, key_file_loc,
-					G_KEY_FILE_NONE, &error);
-	if (!ret) {
-		g_error_free(error);
-		g_key_file_free(file);
-		file = NULL;
-
-		goto out;
-	}
-
-	g_clear_error(&error);
-
- out:
-	if (!key_file_env && key_file_loc)
-		free(key_file_loc);
-
-	return file;
-}
-
 static void common_init_config(void)
 {
 	GError *error = NULL;
lib/igt_core.h +0 -2
index 3337293bc..afaf35aa8 100644
@@ -95,8 +95,6 @@ extern const char* __igt_test_description __attribute__((weak));
 extern bool __igt_plain_output;
 extern char *igt_frame_dump_path;
 
-struct _GKeyFile *igt_load_igtrc(void);
-
 /**
  * IGT_TEST_DESCRIPTION:
  * @str: description string
lib/igt_device_scan.c +48 -0

57 lines not on this page · raw message

lib/igt_device_scan.h +2 -0
index f24a193cd..5b04033e3 100644
@@ -103,4 +103,6 @@ int igt_open_render(struct igt_device_card *card);
 /* Add or use filters to match multiGPU devices */
 int igt_device_prepare_filtered_view(const char *vendor);
 
+struct _GKeyFile *igt_load_igtrc(void);
+
 #endif /* __IGT_DEVICE_SCAN_H__ */
Signature · 1 line
2.53.0
#62 lore raw

Re: [PATCH i-g-t v2 30/31] lib/igt_core: move igt_load_igtrc to igt_device_scan

Quoted 9 lines · Sebastian Brzezinka

igt_load_igtrc() is used exclusively by igt_device_scan internals to read per-device configuration from the igtrc file. Moving it from igt_core.c to igt_device_scan.c co-locates the function with its primary user and makes it possible for lsgpu to link against lib_igt_device_scan without needing the rest of libigt.

Update the declaration accordingly: remove from igt_core.h and add to igt_device_scan.h where the implementation now lives.

What happens to runner/executor.c? It's also calling igt_load_igtrc() directly, and is including igt_core.h both before and after the patch.

Quoted 148 lines
---
 lib/igt_core.c        | 47 ------------------------------------------
 lib/igt_core.h        |  2 --
 lib/igt_device_scan.c | 48 +++++++++++++++++++++++++++++++++++++++++++
 lib/igt_device_scan.h |  2 ++
 4 files changed, 50 insertions(+), 49 deletions(-)
lib/igt_core.c +0 -47
index a7c097d9e..2f737b01a 100644
@@ -972,53 +972,6 @@ static void oom_adjust_for_doom(void)
 
 }
 
-/**
- * load_igtrc:
- *
- * Load .igtrc from the path pointed to by #IGT_CONFIG_PATH or from
- * home directory if that is not set. The returned keyfile needs to be
- * deallocated using g_key_file_free().
- *
- * Returns: Pointer to the keyfile, NULL on error.
- */
-GKeyFile *igt_load_igtrc(void)
-{
-	char *key_file_env = NULL;
-	char *key_file_loc = NULL;
-	GError *error = NULL;
-	GKeyFile *file;
-	int ret;
-
-	/* Determine igt config path */
-	key_file_env = getenv("IGT_CONFIG_PATH");
-	if (key_file_env) {
-		key_file_loc = key_file_env;
-	} else {
-		key_file_loc = malloc(100);
-		snprintf(key_file_loc, 100, "%s/.igtrc", g_get_home_dir());
-	}
-
-	/* Load igt config file */
-	file = g_key_file_new();
-	ret = g_key_file_load_from_file(file, key_file_loc,
-					G_KEY_FILE_NONE, &error);
-	if (!ret) {
-		g_error_free(error);
-		g_key_file_free(file);
-		file = NULL;
-
-		goto out;
-	}
-
-	g_clear_error(&error);
-
- out:
-	if (!key_file_env && key_file_loc)
-		free(key_file_loc);
-
-	return file;
-}
-
 static void common_init_config(void)
 {
 	GError *error = NULL;
lib/igt_core.h +0 -2
index 3337293bc..afaf35aa8 100644
@@ -95,8 +95,6 @@ extern const char* __igt_test_description __attribute__((weak));
 extern bool __igt_plain_output;
 extern char *igt_frame_dump_path;
 
-struct _GKeyFile *igt_load_igtrc(void);
-
 /**
  * IGT_TEST_DESCRIPTION:
  * @str: description string
lib/igt_device_scan.c +48 -0
index 7c7995224..a15a4624e 100644
@@ -33,6 +33,7 @@
 #include <ctype.h>
 #include <dirent.h>
 #include <fcntl.h>
+#include <glib.h>
 #include <libudev.h>
 #ifdef __linux__
 #include <linux/limits.h>
@@ -2477,3 +2478,50 @@ int igt_device_prepare_filtered_view(const char *vendor)
 
 	return gpu_count;
 }
+
+/**
+ * igt_load_igtrc:
+ *
+ * Load .igtrc from the path pointed to by #IGT_CONFIG_PATH or from
+ * home directory if that is not set. The returned keyfile needs to be
+ * deallocated using g_key_file_free().
+ *
+ * Returns: Pointer to the keyfile, NULL on error.
+ */
+GKeyFile *igt_load_igtrc(void)
+{
+	char *key_file_env = NULL;
+	char *key_file_loc = NULL;
+	GError *error = NULL;
+	GKeyFile *file;
+	int ret;
+
+	/* Determine igt config path */
+	key_file_env = getenv("IGT_CONFIG_PATH");
+	if (key_file_env) {
+		key_file_loc = key_file_env;
+	} else {
+		key_file_loc = malloc(100);
+		snprintf(key_file_loc, 100, "%s/.igtrc", g_get_home_dir());
+	}
+
+	/* Load igt config file */
+	file = g_key_file_new();
+	ret = g_key_file_load_from_file(file, key_file_loc,
+					G_KEY_FILE_NONE, &error);
+	if (!ret) {
+		g_error_free(error);
+		g_key_file_free(file);
+		file = NULL;
+
+		goto out;
+	}
+
+	g_clear_error(&error);
+
+ out:
+	if (!key_file_env && key_file_loc)
+		free(key_file_loc);
+
+	return file;
+}
lib/igt_device_scan.h +0 -0
index f24a193cd..5b04033e3 100644

lib/igt_device_scan.h int igt_open_render(struct igt_device_card *card); · line 107

Quoted 5 lines
lib/igt_device_scan.h +2 -0
@@ -103,4 +103,6 @@ int igt_open_render(struct igt_device_card *card);
 /* Add or use filters to match multiGPU devices */
 int igt_device_prepare_filtered_view(const char *vendor);
 
+struct _GKeyFile *igt_load_igtrc(void);
+

Maybe it's just me but using the typedefed GKeyFile in the definition and the non-typedefed struct _GKeyFile in the declaration seems a bit weird, is there a reason why they don't match? If not it's a bit more readable IMO to have them match but this might be out of scope of the patch.

Thanks
Krzysztof

Quoted 4 lines
lib/igt_device_scan.h +0 -0
 #endif /* __IGT_DEVICE_SCAN_H__ */
Signature · 1 line
2.53.0
#63 lore raw

PATCH v2 31/31 tools/lsgpu: link with minimal sub-libraries

In reply to Sebastian Brzezinka

lsgpu only needs device enumeration and the lightweight tool stubs. Replace #include "igt.h" with the minimal header set and stop linking against libigt.so.

ldd before: 35 (ldd | wc -l)
ldd after: 8 (ldd | wc -l)

---
 tools/lsgpu.c     | 2 +-
 tools/meson.build | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)
tools/lsgpu.c +1 -1
index 935371dea..7d6b70b9b 100644
@@ -34,7 +34,7 @@
 #include <signal.h>
 #include <sys/ioctl.h>
 
-#include "igt.h"
+#include "igt_core.h"
 #include "igt_device_scan.h"
 
 /**
tools/meson.build +6 -1
index 6e694164f..fbc6c0a00 100644
@@ -27,7 +27,6 @@ tools_progs = [
 	'intel_tiling_detect',
 	'intel_gem_info',
 	'dpcd_reg',
-	'lsgpu',
 ]
 tool_deps = igt_deps
 tool_deps += zlib
@@ -172,6 +171,12 @@ install_data(['intel_gpu_abrt', 'intel-gfx-fw-info'], install_dir : bindir)
 
 install_subdir('registers', install_dir : datadir)
 
+executable('lsgpu', 'lsgpu.c',
+	   dependencies : [lib_igt_device_scan, lib_igt_tools_stub,
+	                    lib_igt_drm_stub, glib, libudev, libpci],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 executable('intel_gpu_top', 'intel_gpu_top.c',
 	   install : true,
 	   install_rpath : bindir_rpathdir,
Signature · 1 line
2.53.0
Reviewed-by on v2 31/31
#64 lore raw

Re: [PATCH i-g-t v2 31/31] tools/lsgpu: link with minimal sub-libraries

Quoted 43 lines · Sebastian Brzezinka

lsgpu only needs device enumeration and the lightweight tool stubs. Replace #include "igt.h" with the minimal header set and stop linking against libigt.so.

ldd before: 35 (ldd | wc -l)
ldd after: 8 (ldd | wc -l)

---
 tools/lsgpu.c     | 2 +-
 tools/meson.build | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)
tools/lsgpu.c +1 -1
index 935371dea..7d6b70b9b 100644
@@ -34,7 +34,7 @@
 #include <signal.h>
 #include <sys/ioctl.h>
 
-#include "igt.h"
+#include "igt_core.h"
 #include "igt_device_scan.h"
 
 /**
tools/meson.build +0 -1
index 6e694164f..fbc6c0a00 100644
@@ -27,7 +27,6 @@ tools_progs = [
 	'intel_tiling_detect',
 	'intel_gem_info',
 	'dpcd_reg',
-	'lsgpu',
 ]
 tool_deps = igt_deps
 tool_deps += zlib
@@ -172,6 +171,12 @@ install_data(['intel_gpu_abrt', 'intel-gfx-fw-info'], install_dir : bindir)
 
 install_subdir('registers', install_dir : datadir)

tools/meson.build install_data(['intel_gpu_abrt', 'intel-gfx-fw-info'], install_dir : bindir) · line 182

Quoted 10 lines
tools/meson.build +6 -0
 
+executable('lsgpu', 'lsgpu.c',
+	   dependencies : [lib_igt_device_scan, lib_igt_tools_stub,
+	                    lib_igt_drm_stub, glib, libudev, libpci],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 executable('intel_gpu_top', 'intel_gpu_top.c',
 	   install : true,
 	   install_rpath : bindir_rpathdir,

Thanks
Krzysztof

Quoted 2 lines

2.53.0

#65 lore raw

Re: [PATCH i-g-t v2 31/31] tools/lsgpu: link with minimal sub-libraries

In reply to Sebastian Brzezinka

Hi Sebastian,

Quoted 7 lines · Sebastian Brzezinka

lsgpu only needs device enumeration and the lightweight tool stubs. Replace #include "igt.h" with the minimal header set and stop linking against libigt.so.

ldd before: 35 (ldd | wc -l)
ldd after: 8 (ldd | wc -l)

Please add Closes: tag here.

Regards,
Kamil

Quoted 48 lines
---
 tools/lsgpu.c     | 2 +-
 tools/meson.build | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)
tools/lsgpu.c +1 -1
index 935371dea..7d6b70b9b 100644
@@ -34,7 +34,7 @@
 #include <signal.h>
 #include <sys/ioctl.h>
 
-#include "igt.h"
+#include "igt_core.h"
 #include "igt_device_scan.h"
 
 /**
tools/meson.build +6 -1
index 6e694164f..fbc6c0a00 100644
@@ -27,7 +27,6 @@ tools_progs = [
 	'intel_tiling_detect',
 	'intel_gem_info',
 	'dpcd_reg',
-	'lsgpu',
 ]
 tool_deps = igt_deps
 tool_deps += zlib
@@ -172,6 +171,12 @@ install_data(['intel_gpu_abrt', 'intel-gfx-fw-info'], install_dir : bindir)
 
 install_subdir('registers', install_dir : datadir)
 
+executable('lsgpu', 'lsgpu.c',
+	   dependencies : [lib_igt_device_scan, lib_igt_tools_stub,
+	                    lib_igt_drm_stub, glib, libudev, libpci],
+	   install_rpath : bindir_rpathdir,
+	   install : true)
+
 executable('intel_gpu_top', 'intel_gpu_top.c',
 	   install : true,
 	   install_rpath : bindir_rpathdir,
Signature · 1 line
2.53.0
#66 lore raw
In reply to Sebastian Brzezinka

Hi Sebastian,

Quoted 35 lines · Sebastian Brzezinka

This issue was raised by the community back in 2019:
https://bugs.freedesktop.org/show_bug.cgi?id=110249

Standalone tools linked libigt.so as a side effect, pulling in cairo, pixman and libX11 even without framebuffer use.

Following intel_gpu_top's approach, each tool now links only the static sub-libraries it needs. Five new ones are introduced:

lib_igt_tools_stub, lib_igt_drm_stub, lib_igt_halffloat, lib_i915_decode, lib_igt_reg_tools.

igt_load_igtrc() is moved to igt_device_scan.c so lsgpu can use lib_igt_device_scan without pulling in libigt.so.

All 20 tools: 35 shared libs -> 3-8.

Behavioural differences vs original binaries (no-hardware runs):

intel_backlight, intel_lid, intel_gpu_time, intel_audio_dump, intel_infoframes, intel_panel_fitter, intel_firmware_decode:
assertion failure format: IGT CRITICAL block -> single-line message; exit code: 98 (IGT_EXIT_FAILURE) -> 1.

intel_gtt, intel_display_poller, intel_watermark:
same as above; additionally print an extra "Test requirement passed:
pci_dev" line on stderr (previously suppressed by IGT log layer).

intel_guc_logger:
same exit code change (98->1); --help drops IGT framework options (--list-subtests, --run-subtest, --device, etc.) which had no effect on guc_logger since it opens debugfs directly, not via IGT device selection; --version, --debug, --hook also removed. Unknown option exit code: 79 (IGT_EXIT_INVALID) -> 1.

Quoted 3 lines

intel_gvtg_test:
skip message: IGT skip block -> single-line; exit code unchanged (77).

I'm halfway through reading your series, and I can't help but think that this series is only remedying the real problem of building almost everything in the lib/ folder as one big shared library. We're putting literally everything in libigt.so, even though at the source level everything is split nicely into .c and .h files. Correct me if I'm understanding the build system wrong but it looks like we're already even building static libraries for all the little files in lib/, and linking them into libigt.so at the end.

I guess at this point this is a matter of a tradeoff, because all tests depend on libigt.so; after splitting its contents into smaller shared objects it would be almost a herculean task to isolate the correct dependencies in all the tests. If it was done from the start it would be very much feasible, because tests and its build files would be written with that in mind, but you know, benefit of hindsight.

And then if the core libs would have been split more properly, this series wouldn't be really needed - the tools would just include and link what they need.

So this series is solving the problem very pragmatically in my opinion, to my mind it should absolutely go in. However, I think we should assess whether it's worth leaving at least a "TODO: modularize libigt.so" somewhere, so it could be addressed at some point in the future.

Thanks
Krzysztof

#67 lore raw

Hi,

Quoted 42 lines · Krzysztof Niemiec

Hi Sebastian,

Quoted 35 lines · Sebastian Brzezinka

This issue was raised by the community back in 2019:
https://bugs.freedesktop.org/show_bug.cgi?id=110249

Standalone tools linked libigt.so as a side effect, pulling in cairo, pixman and libX11 even without framebuffer use.

Following intel_gpu_top's approach, each tool now links only the static sub-libraries it needs. Five new ones are introduced:

lib_igt_tools_stub, lib_igt_drm_stub, lib_igt_halffloat, lib_i915_decode, lib_igt_reg_tools.

igt_load_igtrc() is moved to igt_device_scan.c so lsgpu can use lib_igt_device_scan without pulling in libigt.so.

All 20 tools: 35 shared libs -> 3-8.

Behavioural differences vs original binaries (no-hardware runs):

intel_backlight, intel_lid, intel_gpu_time, intel_audio_dump, intel_infoframes, intel_panel_fitter, intel_firmware_decode:
assertion failure format: IGT CRITICAL block -> single-line message; exit code: 98 (IGT_EXIT_FAILURE) -> 1.

intel_gtt, intel_display_poller, intel_watermark:
same as above; additionally print an extra "Test requirement passed:
pci_dev" line on stderr (previously suppressed by IGT log layer).

intel_guc_logger:
same exit code change (98->1); --help drops IGT framework options (--list-subtests, --run-subtest, --device, etc.) which had no effect on guc_logger since it opens debugfs directly, not via IGT device selection; --version, --debug, --hook also removed. Unknown option exit code: 79 (IGT_EXIT_INVALID) -> 1.

Quoted 3 lines

intel_gvtg_test:
skip message: IGT skip block -> single-line; exit code unchanged (77).

Quoted 8 lines

I'm halfway through reading your series, and I can't help but think that this series is only remedying the real problem of building almost everything in the lib/ folder as one big shared library. We're putting literally everything in libigt.so, even though at the source level everything is split nicely into .c and .h files. Correct me if I'm understanding the build system wrong but it looks like we're already even building static libraries for all the little files in lib/, and linking them into libigt.so at the end.

+1

Quoted 8 lines

I guess at this point this is a matter of a tradeoff, because all tests depend on libigt.so; after splitting its contents into smaller shared objects it would be almost a herculean task to isolate the correct dependencies in all the tests. If it was done from the start it would be very much feasible, because tests and its build files would be written with that in mind, but you know, benefit of hindsight.

Quoted 8 lines

And then if the core libs would have been split more properly, this series wouldn't be really needed - the tools would just include and link what they need.

So this series is solving the problem very pragmatically in my opinion, to my mind it should absolutely go in. However, I think we should assess whether it's worth leaving at least a "TODO: modularize libigt.so" somewhere, so it could be addressed at some point in the future.

It might be worth figuring out why we are where we are. Was "build everything into a library and suff as much into it as possible" a conscious decision or a design oversight?

I imagine this might have never came up as a point before, so it would be worth checking with the maintainers.

Signature · 2 lines
Best Regards,
Krzysztof
#68 lore raw

Hi Krzysztof,

Quoted 71 lines · Krzysztof Karas

Hi,

Quoted 42 lines · Krzysztof Niemiec

Hi Sebastian,

Quoted 35 lines · Sebastian Brzezinka

This issue was raised by the community back in 2019:
https://bugs.freedesktop.org/show_bug.cgi?id=110249

Standalone tools linked libigt.so as a side effect, pulling in cairo, pixman and libX11 even without framebuffer use.

Following intel_gpu_top's approach, each tool now links only the static sub-libraries it needs. Five new ones are introduced:

lib_igt_tools_stub, lib_igt_drm_stub, lib_igt_halffloat, lib_i915_decode, lib_igt_reg_tools.

igt_load_igtrc() is moved to igt_device_scan.c so lsgpu can use lib_igt_device_scan without pulling in libigt.so.

All 20 tools: 35 shared libs -> 3-8.

Behavioural differences vs original binaries (no-hardware runs):

intel_backlight, intel_lid, intel_gpu_time, intel_audio_dump, intel_infoframes, intel_panel_fitter, intel_firmware_decode:
assertion failure format: IGT CRITICAL block -> single-line message; exit code: 98 (IGT_EXIT_FAILURE) -> 1.

intel_gtt, intel_display_poller, intel_watermark:
same as above; additionally print an extra "Test requirement passed:
pci_dev" line on stderr (previously suppressed by IGT log layer).

intel_guc_logger:
same exit code change (98->1); --help drops IGT framework options (--list-subtests, --run-subtest, --device, etc.) which had no effect on guc_logger since it opens debugfs directly, not via IGT device selection; --version, --debug, --hook also removed. Unknown option exit code: 79 (IGT_EXIT_INVALID) -> 1.

Quoted 3 lines

intel_gvtg_test:
skip message: IGT skip block -> single-line; exit code unchanged (77).

Quoted 8 lines

I'm halfway through reading your series, and I can't help but think that this series is only remedying the real problem of building almost everything in the lib/ folder as one big shared library. We're putting literally everything in libigt.so, even though at the source level everything is split nicely into .c and .h files. Correct me if I'm understanding the build system wrong but it looks like we're already even building static libraries for all the little files in lib/, and linking them into libigt.so at the end.

+1

Quoted 8 lines

I guess at this point this is a matter of a tradeoff, because all tests depend on libigt.so; after splitting its contents into smaller shared objects it would be almost a herculean task to isolate the correct dependencies in all the tests. If it was done from the start it would be very much feasible, because tests and its build files would be written with that in mind, but you know, benefit of hindsight.

Quoted 8 lines

And then if the core libs would have been split more properly, this series wouldn't be really needed - the tools would just include and link what they need.

So this series is solving the problem very pragmatically in my opinion, to my mind it should absolutely go in. However, I think we should assess whether it's worth leaving at least a "TODO: modularize libigt.so" somewhere, so it could be addressed at some point in the future.

Quoted 6 lines

It might be worth figuring out why we are where we are. Was "build everything into a library and suff as much into it as possible" a conscious decision or a design oversight?

I imagine this might have never came up as a point before, so it would be worth checking with the maintainers.

Or git logs?

That was when igt project moved from autotools to meson. I guess it was ok for developers to have just one big linked lib. Later users filed ticket(s) on GitLab.

Regards,
Kamil

Quoted 4 lines
Signature · 3 lines
-- 
Best Regards,
Krzysztof
#69 lore raw
In reply to Sebastian Brzezinka

Hi Sebastian,

Quoted 9 lines · Sebastian Brzezinka

This issue was raised by the community back in 2019:
https://bugs.freedesktop.org/show_bug.cgi?id=110249

Standalone tools linked libigt.so as a side effect, pulling in cairo, pixman and libX11 even without framebuffer use.

Following intel_gpu_top's approach, each tool now links only the static sub-libraries it needs. Five new ones are introduced:

Quoted 7 lines

lib_igt_tools_stub, lib_igt_drm_stub, lib_igt_halffloat, lib_i915_decode, lib_igt_reg_tools.

igt_load_igtrc() is moved to igt_device_scan.c so lsgpu can use lib_igt_device_scan without pulling in libigt.so.

All 20 tools: 35 shared libs -> 3-8.

Also, maybe it's worth copying an example ld output here for one of the tools, just to paint a better picture of how this series is improving the linking process.

Thanks
Krzysztof